查找整数 编程总结

it2022-05-05  126

查找整数 本题要求从输入的N个整数中查找给定的X。如果找到,输出X的位置(从0开始数);如果没有找到,输出“Not Found”。

一、实验代码

#include<stdio.h> int main() { int i,n,x,count=0; scanf("%d %d",&n, &x); int a[20]; for(i=0;i<n;i++) { scanf("%d",&a[i]); if(a[i]==x) { printf("%d",i); count++; } } if(count==0) { printf("Not Found"); } return 0; }

二、设计思路

三、本题调试过程碰到问题及解决办法

发现c++运行结果图中Not Foound的F没有大写

四、运行结果截图

转载于:https://www.cnblogs.com/ZHLJ477/p/10461873.html


最新回复(0)