题解 | #找x#
找x
https://www.nowcoder.com/practice/069e2130430c41229ab25e47fa0949a6
#include "stdio.h" #include "algorithm" using namespace std; int main(){ int n; int num[200]; int x,flag=-1; while (scanf("%d",&n)!=EOF){ flag=-1; for (int i = 0; i < n; ++i) { scanf("%d",&num[i]); } scanf("%d",&x); for (int i = 0; i < n; ++i) { if(num[i]==x){ flag=i; break; } } printf("%d\n",flag); } }