题解 | #判断元素是否出现#

判断元素是否出现

https://www.nowcoder.com/practice/0787459e92bc4360ba48b094b7f21577

#include<bits/stdc++.h>
using namespace std;
int main(){
	//write your code here......
	int n,m;
	cin>>n>>m;
	int i=1,a;
	set<int> s;
	while(i<=n&&cin>>a)
	{
		s.insert(a);
		i++;
	}
	while(m!=0)
	{
		int x;
		cin>>x;
		set<int>::iterator it1;
		it1=s.find(x);
		if(it1!=s.end())
		{
			cout<<"yes"<<endl;
		}
		else {
			cout<<"no"<<endl;
		}
		m--;
	}
	return 0;
}

全部评论

相关推荐

迷茫的大四🐶:💐孝子启动失败,改为启动咏鹅
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务