答案如下:
#include<bits/stdc++.h>
using namespace std;
#define maxn 10010
int main()
{
int n1,n2,kase=0;
while(scanf("%d%d",&n1,&n2)==2&&n1)
{
int stone[maxn],want[maxn];
for(int i=0;i<n1;i++)
cin>>stone[i];
for(int i=0;i<n2;i++)
cin>>want[i];
sort(stone,stone+n1);
printf(“CASE# %d:\n”,++kase);
for(int i=0;i<n2;i++)
{
int x=lower_bound(stone,stone+n1,want[i])-stone;
if(stone[x]==want[i])
printf("%d found at %d\n",want[i],x+1);
else
printf("%d not found\n",want[i]);
}
}
return 0;
}
Where is the Marble? UVA10474
最新推荐文章于 2022-11-06 17:40:38 发布