C++ 与STL 入门之一:
1.lower_bound(a, a+n, x);
2.sort(a, a+n);
#include <bits/stdc++.h>
using namespace std;
int a[12121211];
int main()
{
int n, m;
int c = 1, x;
while(scanf("%d %d", &n, &m)==2&&n&&m)
{
for(int i=0;i<n;i++)
cin>>a[i];
sort(a, a+n);//排序
cout<<"CASE# "<<c<<':'<<endl;
c++;
for(int i=0;i<m;i++)
{
cin>>x;
int p = lower_bound(a, a+n, x) - a;//lower_bound函数用来查找大于或者等于某个数的第一个位置
if(a[p]==x)
cout<<x<<" found at "<<p+1<<endl;
else
cout<<x<<" not found"<<endl;
}
}
return 0;
}