#include "stdafx.h"
#include
int main(int argc, char* argv[])
{
/* printf("Hello World!\n");*/
int temp[10000];
int temp2[10000];
int temp3;
int temp4;
int count = 1;
while(count<10000)
{
again:
temp[count] = 50000*rand()/RAND_MAX; //产生随机数字 0~50000
for(int j=1;j
if(temp[count]==temp[j]) //判断是否重复
goto again;
}
// 进行插入排序
if(count == 1)
{
temp2[1] = temp[1];
}
else
{
temp3 = temp[count];
for(int i=1;i
if(temp3>temp2[i])
{
temp4=temp2[i];
temp2[i] = temp3;
temp3 = temp4;
}
}
}
count++;
}
//输出
for(int n=1;n<10000;n++)
{
printf("%d,",temp2[n]);
}
return 0;
}
#include
#include
#include
#define _ 100
int main()
{
int __[_][_],*___=__,*____, _____, ______=0;
srand((unsigned)time(NULL));
while(___ < __+_)
{
______=0;
____=__;
_____=rand()%50000+1;
while(____<___) (_____==*____)? (______=1,--___,++____):++____;
______?______=0:(*___=_____, printf("%d\t", *___));
++___;
}
}
直接复制到编译器,运行就行,但是结果没有排序。
要产生不同的随机数,就要改变每次的随机数种子,这样的随机数是每次不同的