#include"stdio.h"
int main()
{
int a[5];
int i,flag=0,index,x;
for(i=0;i<5;i++)
scanf("%d",&a[i]);
printf("Give the x:");
scanf("%d",&x);
for(i=0;i<5;i++){
if(a[i]==x){
flag=1;
index=i;
break;
}
}
if(flag)
printf("x is founded and the index is %d!\n",index);
else
printf("x is not founded!\n");
return 0;
}
顺序查找法
最新推荐文章于 2024-09-22 11:41:42 发布