标签:http title can .com img out ++ i++ lan
本题要求从输入的N个整数中查找给定的X。如果找到,输出X的位置(从0开始数);如果没有找到,输出“Not Found”。
输入在第一行中给出两个正整数N(≤20)和X,第二行给出N个整数。数字均不超过长整型,其间以空格分隔。
在一行中输出X的位置,或者“Not Found”。
5 7
3 5 7 1 9
2
5 7
3 5 8 1 9
Not Found
实验代码:
#include<stdio.h> main() { int N,X; scanf("%d%d",&N,&X); int a[N]; for(int i=0;i<N;i++) { scanf("%d",&a[i]); } for(int i=0;i<N;i++) { if(X==a[i]) { printf("%d",i); break; } else if(i==N-1) { printf("Not Found"); } } }
运行截图:
标签:http title can .com img out ++ i++ lan
原文地址:https://www.cnblogs.com/lwl123456789/p/10466948.html