首页 > 代码库 > 杭电2019

杭电2019

杭电2019

#include <iostream>#include <cstdlib>#include <cmath>#include <iomanip>#include <climits>#include <stdio.h>#include <string.h>#include <list>using namespace std;int main(){    list<int> a;    int n,m,t;    while(cin >> n >> m && (n!=0||m!=0))    {        a.clear();        while(n--)        {            cin>>t;            a.push_back(t);        }        a.push_back(m);        a.sort();        for(list<int>::iterator it = a.begin();it!=a.end();++it)        {            cout << *it;            advance(it,1);            if (it!=a.end()) cout <<  ;            else cout << endl;            advance(it,-1);        }    }    return 0;}

用了STL,很方便啊。。不过有点浪费的感觉。

杭电2019