题解 | #有序序列插入一个整数#sort大法好
有序序列插入一个整数
https://www.nowcoder.com/practice/444e87f938464906a1649cff236b102b
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> vec; while (n--) { int num; cin >> num; vec.push_back(num); } int other; cin >> other; vec.push_back(other); sort(vec.begin(), vec.end()); for (auto e : vec) cout << e << " "; } // 64 位输出请用 printf("%lld")