#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/*
(0,0) (0,1) (0,2)
(1,0) (1,1) (1,2)
(2,0) (2,1) (2,2)
*/
int main(int argc, char *argv[])
{
srand(time(NULL));
int table[10]={0};
table[0]=rand()%999+1;
table[1]=rand()%999+1;
table[2]=rand()%999+1;
table[3]=rand()%999+1;
table[4]=rand()%999+1;
table[5]=rand()%999+1;
table[6]=rand()%999+1;
table[7]=rand()%999+1;
table[8]=rand()%999+1;
table[9]=rand()%999+1;
int i,j;
for(i=0;i<10;i++)
{
for(j=0;j<10-i;j++)
{
if(table[j]>table[j+1])
{
int temp = table[j];
table[j]=table[j+1];
table[j+1]=temp;
}
}
}
for(i=0;i<10;i++)
{
printf(" %d ",table[i]);
}
return 0;
}
沒有留言:
張貼留言