码迷,mamicode.com
首页 > 其他好文 > 详细

数组-04. 查找整数

时间:2014-08-23 01:01:09      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   for   ar   2014   

 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\n",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

 

数组-04. 查找整数

标签:style   blog   http   color   os   io   for   ar   2014   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!