using namespace std;
void sequence_search(int *arr, int num, int key)
{
while (arr[num] != key)
{
num--;
}
if (arr[num] == key && num != 0)
{
cout << "找到了数字" << arr[num] << endl;
}
else
{
cout << "没有找到!" << endl;
}
}
int main()
{
int num = 0, key = 0;
cout << "请输入要查找的序列个数:" << endl;
cin >> num;
int *arr = new int[num + 1];
cout << "请输入要查找的序列:" << endl;
for (int i = 1; i < num + 1; i++)
{
cin >> arr[i];
}
while (key != 65535)
{
cout << "请输入要查找的数字:" << endl;
cin >> key;
arr[0] = key;
sequence_search(arr, num, key);
}
system("pause");
return 0;
}