这是一个简单的顺序查找
#include <iostream>
#include <string>
using namespace std;
int main()
{
int _myList[10001];
int n;
cin >> n;
for(int i = 1; i <= n; i++)
{
int t;
cin >> t;
_myList[i] = t;
}
int find;
cin >> find;
int num;
for(int i = 1; i <= n; i++)
{
if(_myList[i] == find){
num = i;
cout << num << endl;
return 0;
}
}
cout << "-1" << endl;
return 0;
}