已知数组a[]={0,1,2,3,4,5,6,7,8,9},判断输入的x是否在该数组中。
怎么写?
#include <stdio.h>
int main(void)
{
int a[] = {0,1,2,3,4,5,6,7,8,9};
int i,x;
scanf("%d", &x);
for(i=0;i<10;i++)
if(a[i]==x)
break;
if(i>=10)
printf("not found\n");
else
printf("found\n");
return;
}
int main(void)
{
int a[] = {0,1,2,3,4,5,6,7,8,9};
int i,x;
scanf("%d", &x);
for(i=0;i<10;i++)
if(a[i]==x)
break;
if(i>=10)
printf("not found\n");
else
printf("found\n");
return;
}
温馨提示:答案为网友推荐,仅供参考