题解 P1177 【【模板】快速排序】

应该没人用multiset吧?我来一发,所谓multiset,就是可放重复元素的集合,和set一样,里面的元素可以自动排序!!!

#include<cstdio>
#include<set>
#define ll long long
using namespace std;
multiset<ll>so;//STL大法好
ll n,x;
int main()
{
    scanf("%ld",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%ld",&x);
        so.insert(x);//插入multiset,会自动排序
    }
    multiset<ll>::iterator it;//迭代器
    for(it=so.begin();it!=so.end();it++)//轻松遍历一遍
    printf("%ld ",*it);
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/N-S-P/p/10802069.html