C语言编程,随机生成十个数,并对这十个数排序,程序怎么写?求助!

如题所述

第1个回答  推荐于2017-09-07
#include<stdio.h>
#include<stdlib.h>

int main()
{
int i,j;
unsigned seed;
int a[10];
printf("please input seed");
scanf("%d",&seed);
srand(seed);
for(i = 0; i < 10; i++)
a[i] = rand() ;
for(i = 0; i < 10 ; i++)
for(j = i+1; j < 10; j++)
{
if(a[i]>a[j])
{
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
for(i = 0;i < 10; i++)
printf("%d\t",a[i]);
printf("\n");
return 0;
}本回答被提问者采纳
第2个回答  2015-04-30
去百度吧,我学到这已经好久没学了
相似回答