Problem C: 零起点学算法82——数组中查找数

#include <stdio.h>

int main(int argc, char *argv[])
{
    int n,b,i,m,flag=0,a[20];
    while(scanf("%d",&n)!=EOF){
        for(i=0;i<n;i++){
            scanf("%d",&a[i]);
        }
        scanf("%d",&m);
        for(i=0;i<n;i++){
        if(a[i]==m){
            b=i;
            flag=1;
            break;
         }
        }
        if(flag==1){
        printf("%d\n",b);
        }
        else{
        printf("No\n");
        }
        flag=0;
    }
    return 0;
}
posted @ 2018-11-09 21:45  阿森纳必胜  阅读(304)  评论(0编辑  收藏  举报