提交时间:2023-09-11 15:17:34

运行 ID: 101958

#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n, m; cin >> n >> m; vector<vector<int>> matrix(n, vector<int>(m)); for(int i = 0; i < n; ++i) for(int j = 0; j < m; ++j) cin >> matrix[i][j]; sort(matrix.begin(), matrix.end()); for(const auto &row : matrix) { for(const auto &num : row) cout << num << ' '; cout << '\n'; } return 0; }