数组-04. 查找整数

 1 /*
 2  * Main.c
 3  * E4-数组-04. 查找整数
 4  *  Created on: 2014年8月20日
 5  *      Author: Boomkeeper
 6  *********测试通过********
 7  */
 8 
 9 #include <stdio.h>
10 
11 int main(void){
12 
13     int N,X;
14     int array[20]={-1};
15 
16     scanf("%d %d",&N,&X);
17     getchar();
18     //获取数组
19     int i;
20     for(i=0;i<N;i++){
21         scanf("%d",&array[i]);
22     }
23     //查找
24     for(i=0;i<N;i++){
25         if(array[i]==X){
26             printf("%d
",i);
27             return 0;
28         }
29     }
30     printf("Not Found");
31 
32     return 0;
33 }

题目链接:

http://pat.zju.edu.cn/contests/basic-programming/%E6%95%B0%E7%BB%84-04

原文地址:https://www.cnblogs.com/boomkeeper/p/E4.html