wrong???
查看原帖
wrong???
322177
cugthehun楼主2021/1/11 18:47

#include<iostream>
#include<algorithm>
using namespace std;


int main()
{
	const int maxn=10005;
	int a[maxn];
	int n,q,x,cases=1,loc;
	bool isfind;
	while(cin>>n>>q&&n)
	{
	 
		isfind=false;
		for(int i=0;i<n;++i)
		cin>>a[i];
		sort(a,a+n);
		cout<<"CASE# "<<cases<<":"<<endl;
		while(q--)
		{
		cin>>x;
		for(int j=0;j<n;++j)
		{
		 if(a[j]==x)
	    {
		 loc=j;
		 cout<<x<<" found at "<<loc+1<<endl;
		 isfind=true;	
		 break;
		}   	
		}
		if(!isfind)
		cout<<x<<" not found"<<endl;	
		}
		++cases;
	}
}
2021/1/11 18:47
加载中...