查找数据是否存在

#include<stdio.h>
#include<stdlib.h>
#include<time.h>

void main()
{
time_t ts;
srand((unsigned int)time(&ts));
int a[10];
for (int i = 0; i < 10; i++)
{
a[10] = rand() % 100;
printf("\n%d,%x", a[10], &a[10]);

}
int num;
scanf("%d",&num);
int flag=0;
for (int i = 0; i < 10; i++)
{
if (num == a[i])
{
flag = 1;
break;
}
}
if (flag == 1)
{
printf("找到");
}
else
{
printf("找不到");
}

system("pause");
}

猜你喜欢

转载自www.cnblogs.com/minTTremor/p/9170442.html
今日推荐