题解 | #找x#
找x
https://www.nowcoder.com/practice/069e2130430c41229ab25e47fa0949a6
#include<cstdio> int main() { int n ; int arr[201]; scanf("%d", &n); for (int i = 0 ; i < n ; ++ i) { scanf("%d", &arr[i]); } int x, idx; scanf("%d", &x); for (idx = 0 ; idx < n ; ++ idx) { if (arr[idx] == x) { printf("%d\n", idx); break; } } if (idx == n) { printf("-1"); } }