#include<stdio.h>
main()
{
int array[10]={1,0,4,8,12,65,-76,100,-45,123};
int location;
int i;
printf("\n输入你要查找的数值:");
scanf("%d",&location);
for (i=0;i<10;i++)
{
if (array[i]==location)
{
printf("%d在数组里\n",location);
break;
}
if (i==9)
printf("%d不在数组里\n",location);
}
}
哦不好意思 应该是这样 呵呵~
main()
{
int array[10]={1,0,4,8,12,65,-76,100,-45,123};
int location;
int i;
printf("\n输入你要查找的数值:");
scanf("%d",&location);
for (i=0;i<10;i++)
{
if (array[i]==location)
{
printf("%d在数组里\n",location);
break;
}
if (i==9)
printf("%d不在数组里\n",location);
}
}
哦不好意思 应该是这样 呵呵~