文章

166

粉丝

68

获赞

825

访问

49.7k

头像
排序去重 题解:一个map,两个任务
P1898 华中科技大学2021年机试
发布于2025年3月15日 12:05
阅读数 116

#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;
    }
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发