洛谷 c++ P1177 【模板】排序 题解
前言
经典的一道纯sort排序题。
思路
定义一个数组,
输入每个变量,
sort排序,
最后输出。
sort排序不会,点这里:
https://blog.csdn.net/DavieDu/article/details/149866103?spm=1001.2014.3001.5502
代码
#include <bits/stdc++.h>
using namespace std;int main (){int n;cin >> n;int a[n] = {};for (int i = 0; i < n; ++i){cin >> a[i];}sort(a, a + n);for (int i = 0; i < n; ++i){cout << a[i] << ' ';}return 0;
}
完结撒花~
有问题或错误请私信我,谢谢!