C++ 查找整数:从 N 个整数中寻找给定的 X
#include <iostream>
using namespace std;
int main() {
int n, x;
cin >> n >> x;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == x) {
cout << i << endl;
return 0;
}
}
cout << 'Not Found' << endl;
return 0;
}
原文地址: https://www.cveoy.top/t/topic/mGDr 著作权归作者所有。请勿转载和采集!