算法笔记_codeup1934(找x)
作者:互联网
我的解法:(注意此处为多组数据,即多点测试)
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
while(scanf("%d",&n) != EOF){
int arr[n];
for(int i = 0; i < n; i++){
cin >> arr[i];
}
int findnum;
scanf("%d", &findnum);
int i;
for(i = 0; i < n; i++){
if(arr[i] == findnum){
printf("%d", i);
break;
}
else
continue;
}
if(i == n)
printf("-1");
}
}
标签:arr,findnum,int,codeup1934,scanf,笔记,++,算法,printf 来源: https://www.cnblogs.com/xuhan74520/p/10615958.html