排序去重 题解:一个map,两个任务
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
while(cin>>n){
map<int,int>mp;
while(n--){
int x;cin>>x;
mp[x]++;
}
for(auto x:mp){
for(int i=0;i<x.second;i++)cout<<x.first<<' ';
}cout<<endl;
for(auto x:mp)cout<<x.first<<' ';
cout<<endl;
}
}
登录后发布评论
暂无评论,来抢沙发