题解 | #找x#
找x
https://www.nowcoder.com/practice/069e2130430c41229ab25e47fa0949a6
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; int main() { int n;//数组大小 int arr[2000]; while (scanf("%d", &n) != EOF) { for (int i = 0; i < n; i++) { scanf("%d", &arr[i]); } int x; scanf("%d", &x); int index = -1; for (int i = 0; i < n; i++) { if (arr[i] == x) { index = i; break; } } printf("%d", index); } } // 64 位输出请用 printf("%lld")