跳到正文

题解

题解:P1177 【模板】排序

LRRabcd约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年3月14日
收录
2025年12月12日
更新
2026年11月2日
篇幅
约 1 分钟
题目
P1177

版本

  1. v1当前

solution\texttt{solution}

直接桶排序即可,我用的是 map。

Code\texttt{Code}

C++
#include<bits/stdc++.h>
using namespace std;
map<int,int>vis;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        vis[x]++;
    }
    for(auto i:vis){
        for(int j=1;j<=i.second;j++){
            cout<<i.first<<" ";
        }
    }
    return 0;
}
原文