/*Description
输入10个整数到一个长度为10的整型数组中,然后输入一个整数,查看该整数是否在刚才得到的数组中,如果在,输出“found”,如果不在,输出“not found”
Input
11 个整数
Output
如果第11个整数在前10个整数中,则输出found
如果第11个整数不在前10个整数中,则输出not found
Sample Input
1 2 3 4 5 6 7 8 9 10
5
Sample Output
found
HINT
*/
#include <iostream>
using namespace std;
int main()
{int i,j,k;
int a[10] ;
for(i=0;i<10;i++)
cin>>a[i];
cin>>j;
k=0;
for(i=0;i<10;i++)
{if(a[i]==j)
k=1;
}
if(k==0)
cout<<"not found";
if(k==1)
cout<<"found";
return 0;
}
C++ 计166-1 数组---在数组中查找元素
最新推荐文章于 2023-08-15 14:19:01 发布