首页 > 其他 > 详细

STL应用——hdu1412(set)

时间:2017-08-10 09:42:48      阅读:193      评论:0      收藏:0      [点我收藏+]
  • set函数的应用

  • 超级水题

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <queue>
#include <map>
using namespace std;

int n,m;
int a[10005],b[10005];


int main()
{
	while(~scanf("%d%d",&n,&m)){
		set<int> ans;
		int k=0;
		for(int i=0;i<n;i++){
			scanf("%d",&a[i]);
			ans.insert(a[i]);			//set没有定义[]符号 
		}
		for(int j=0;j<m;j++){
			scanf("%d",&b[j]);
			ans.insert(b[j]);
		}
		bool flag = 0;				//为输出符合题意设置的 
		set<int>::iterator it;				//set的迭代器 
		for(it = ans.begin();it != ans.end();it++){
			if(flag==1)
				printf(" ");
			flag = 1;
			cout<<*it;
		}
		printf("\n");
	}
	return 0;
}

 

STL应用——hdu1412(set)

原文:http://www.cnblogs.com/xzxl/p/7337093.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!