源代码:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>//使用当前时钟做种子
int main()
{
int i,a,l,s,d,y;
int arr[10];
int n = 2;
while (1)
{
for (l = 0; l < 10; l++)
{
a = rand() % 10;
arr[l] = a;
}
for(s=0;s<10;s++)
{
n = 2;
for (d = s+1; d <10; d++)
{
if (arr[s] == arr[d])
{
n = 0;
}
}
if (n == 0)
break;
else
continue;
}
if (n == 2)
break;
}
int m,b;
for (m = 0; m <= 5; m++) {
printf("请输入一个随机数:\n");
scanf_s("%d", &b);
printf("随机抽取的数是:\n");
printf("%d\n", arr[b]);
}
}