题解 | #有序序列合并#用sort函数
有序序列合并
https://www.nowcoder.com/practice/a9e943b0dab142759807d0cfb6863897
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> vec; int num; while (n--) { cin >> num; vec.push_back(num); } while (m--) { cin >> num; vec.push_back(num); } sort(vec.begin(), vec.end()); for (auto e : vec) cout << e << " "; } // 64 位输出请用 printf("%lld")
vector + algorithm 的函数真好用