这里可以直接用C++封装的sort实现升序
#include<list>
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n,x;
    while(scanf("%d",&n)!=EOF)
    {
        list<int> a;
        while(n--){
            scanf("%d",&x);
            a.push_back(x);
        }
        a.sort();
        while(!a.empty())
        {
            printf("%d ",a.front());
            a.pop_front();
        }
        printf("\n");
    }
}
(•̀ᴗ•́)و