《算法竞赛入门经典(第2版)》例题5-1
// 5-1
#include <iostream>
#include <algorithm>
using namespace std;
int stones[10000];
int main()
{
int N, Q, ask, n = 0;
while(cin >> N >> Q && N && Q)
{
cout << "CASE# " << ++n << ":\n";
for(int i = 1; i <= N; i++)
{
cin >> stones[i];
}
sort(stones+1, stones+N+1);
while(Q--)
{
cin >> ask;
int j;
for(j = 1; j <= N; j++)
{
if(ask == stones[j])
{
cout << ask << " found at " << j << endl;
break;
}
}
if(j > N)
{
cout << ask << " not found\n";
}
}
}
return 0;
}