题
本题注意lower_bound 函数的应用,查找大于或等于x的第一个位置 lower_bound(a,a+n,x)
#include <iostream>
#include<algorithm>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int a[10000];
int main(int argc, char** argv) {
int n,q,x,kcase=0;
while(cin>>n>>q&&n){
cout<<"CASE# "<<++kcase<<':'<<endl;
for(int i=0;i<n;i++){
cin>>a[i];
}
sort(a,a+n);
while(q--){
cin>>x;
int p=lower_bound(a,a+n,x)-a;
if(a[p]==x)cout<<x<<" found at "<<p<<endl;
else cout<<x<<" not found"<<endl;
}
}
return 0;
}