码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 2034人见人爱A-B

时间:2015-11-24 01:07:23      阅读:339      评论:0      收藏:0      [点我收藏+]

标签:

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2034

解题思路:set的基本用法

 1 #include<iostream>
 2 #include<string.h>
 3 #include<stdio.h>
 4 #include<set> 
 5 using namespace std;
 6  
 7 int main()
 8 {
 9     int num1,num2,n;
10     while(scanf("%d %d",&num1,&num2)!=EOF)
11     {
12         if(num1 == 0 && num2 == 0)
13             break;
14         else
15         {
16         
17             set<int> set1;
18             set1.clear();
19             for(int i=0;i<num1;i++)
20             {
21                 cin>>n;
22                 set1.insert(n);
23             }
24             
25             for(int i=0;i<num2;i++)
26             {
27                 cin>>n;
28                 set1.erase(n);
29             }
30             
31             if(set1.size()!=0)
32             {
33             
34                 set<int>::iterator it=set1.begin();
35                 
36                 for(;it!=set1.end();it++)
37                 {
38                     cout<<*it<<" ";
39                     
40                 }
41                 cout<<endl;
42             }
43             
44             else
45                 cout<<"NULL\n";
46             
47         }
48         
49      } 
50      return 0;
51 }

 

hdu 2034人见人爱A-B

标签:

原文地址:http://www.cnblogs.com/pter/p/4990154.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!