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