1 #include <bits/stdc++.h> 2 3 using namespace std; 4 5 int n,x; 6 map<int,int>mp; 7 int main() 8 { 9 while(~scanf("%d",&x)){ 10 mp[x]++; 11 } 12 for(auto i:mp){ 13 if(i.second==1)printf("%d\n",i.first); 14 } 15 return 0; 16 }
本文展示了一个使用C++标准库中的map数据结构来统计从标准输入读取的整数出现频率的简单程序。该程序读取一系列整数,利用map来记录每个不同整数出现的次数,并最终输出所有只出现一次的整数。
1 #include <bits/stdc++.h> 2 3 using namespace std; 4 5 int n,x; 6 map<int,int>mp; 7 int main() 8 { 9 while(~scanf("%d",&x)){ 10 mp[x]++; 11 } 12 for(auto i:mp){ 13 if(i.second==1)printf("%d\n",i.first); 14 } 15 return 0; 16 }
转载于:https://www.cnblogs.com/dogenya/p/10815571.html

被折叠的 条评论
为什么被折叠?