//2.创建一个20个大小的随机数组,然后输入一个数,判断是否存在这个数
#include<stdio.h>
#include<time.h>
void main()
{
int num;
time_t ts;
unsigned int data = time(&ts);
srand(data);//创建一个随机种子
int a[20];
scanf_s("%d", &num);
for (int i = 0; i < 20; i++)
{
a[i] = rand() % 100;
if (a[i] == num)
{
printf("%d存在", num);
}
}
for (int i = 0; i < 20; i++)
{
printf("%d ", a[i]);
}
system("pause");
}
#include<stdio.h>
#include<time.h>
void main()
{
int num;
time_t ts;
unsigned int data = time(&ts);
srand(data);//创建一个随机种子
int a[20];
scanf_s("%d", &num);
for (int i = 0; i < 20; i++)
{
a[i] = rand() % 100;
if (a[i] == num)
{
printf("%d存在", num);
}
}
for (int i = 0; i < 20; i++)
{
printf("%d ", a[i]);
}
system("pause");
}