hdu 2034人见人爱A-B

题目链接: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
";
46             
47         }
48         
49      } 
50      return 0;
51 }
原文地址:https://www.cnblogs.com/pter/p/4990154.html