题解 | #迭代器遍历set#

迭代器遍历set

https://www.nowcoder.com/practice/7e57c0f7af86429db20c70053f23ea96

#include<bits/stdc++.h>
using namespace std;
int main(){
	set<int>s;
	int a;
	for(int i=0;i<5;i++)
	{
		cin>>a;
		s.insert(a);
	}
	set<int>::iterator it;
	/*for(it=s.begin();it!=s.end();it++)
	{
		cout<<*it<<" ";

	}*/
	for(const auto& element:s)
	cout<<element<<" ";
	// write your code here......
	return 0;
}

全部评论

相关推荐

notbeentak...:真的nc,算毕业6月份,要给这种b公司打半年多白工😅
点赞 评论 收藏
分享
用微笑面对困难:这里面最强的是驾驶证了,可以入职美团大厂,然后直接开启黄马褂人生
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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