版权声明:本文系作者原创。未经许可,不得转载。
C语言版:
最多支持 1024个,当然可以在源码中修改。不过如果更多,可能数据类型要改,int 要改为 float之类的。
生成的随机数不重复,且每次运行不同。 在ubuntu9.04下gcc编译通过。
#include
#include
#include
#include
#define NUMBER 1024
int main(int argc, char *argv[])
{
int i = 0;
int j = 0;
time_t t;
int num = -1;
int index[NUMBER];
int num_array[NUMBER];
int number;
char buf[8] = {0};
if (argc < 2) {
printf("usage: Should entry the number of the random numbers!\n");
return 0;
}
sprintf(buf, "%s", argv[1]);
number = atoi(buf);
if ( number > NUMBER) {
printf("usage: Max is %d!\n", NUMBER);
return 0;
}
printf("You want t