- initial import

git-svn-id: http://moon:8086/svn/mips@1 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
2014-07-20 15:01:37 +00:00
commit 26291bca3d
1549 changed files with 3997969 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
/* bubble.c */
#include <stdio.h>
#include <stdlib.h>
#define MAX 20000
int a[MAX];
rnum() {
return( rand()%MAX );
}
initran() {
int i;
for(i=0; i<MAX; i++)
a[i] = rnum();
}
bubble() {
int i,j,t;
for(i=MAX-1; i>=0; i--)
for(j=1; j<MAX; j++ )
if ( a[j-1] > a[j] ) {
t = a[j-1];
a[j-1] = a[j];
a[j] = t;
}
}
show(n)
int n;
{
int i;
for(i=0; i<n; i++ ) printf("%d ",a[i]);
printf("\n");
}
main() {
initran();
bubble();
show(10);
}