其实这题也不难,英语不好,没看明白要先排序。。。。。浪费许多时间,真心要学好英语啊
#include<cstdio>
#include<cstdlib>
int comp(void const *a,void const *b)
{
return *(int *)a-*(int *)b;
}
int N=0,Q=0,count=0;
int main()
{
int i=0;
int marbles[10000],queries[10000];
int ok=0;
while((scanf("%d%d",&N,&Q)==2))
{
if(N==0&&Q==0)
return 0;
count++;
for(i=0;i<N;i++)
{
scanf("%d",&marbles[i]);
}
qsort(marbles,N,sizeof(int),comp);
for(i=0;i<Q;i++)
{
scanf("%d",&queries[i]);
}
printf("CASE# %d:\n",count);
for(i=0;i<Q;i++)
{
for(int j=0;j<N;j++)
{
if(queries[i]==marbles[j])
{
printf("%d found at %d\n",queries[i],j+1);
ok=1;
}
if(ok) break;
}
if(ok==0)
{
printf("%d not found\n",queries[i]);
}
ok=0;
}
}
return 0;
}