
#include <iostream>
#include <cstdio>
using namespace std;
const int N = 210;
int x, n;
int d[N];
int main()
{
while (scanf("%d", &n) != EOF)
{
for (int i = 0; i < n; i ++ ) scanf("%d", &d[i]);
cin >> x;
int res = -1;
for (int i = 0; i < n; i ++ )
if (d[i] == x)
{
res = i;
break;
}
cout << res << endl;
}
return 0;
}
多点测试
while (scanf() != EOF){
}
本文介绍了一个使用C++编写的程序,它通过输入一组整数,查找指定值并输出其在数组中的索引。适合初学者理解查找算法在实际编程中的应用。
3926

被折叠的 条评论
为什么被折叠?



