题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2019
题解:
将全部数放入数组中,排序即可。注意输出格式
AC代码:
#include <iostream>
#include <algorithm>
using namespace std;
const int MAXN = 100 + 5;
int A[MAXN];
int main() {
int m, n, temp;
while (cin >> m >> n && m + n) {
A[0] = n;
for(int i = 1; i <= m; i++) {
cin >> A[i];
}
sort(A, A + m + 1);
for(int i = 0; i < m; i++) {
cout << A[i] << " ";
}
cout << A[m] << endl;
}
return 0;
}