Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main() {
- int row, col, n;
- cin >> row >> col;
- vector<vector<int>> matrix;
- for (int i = 0; i < row; i++) {
- vector<int> currentRow;
- for (int j = 0; j < col; j++) {
- cin >> n;
- currentRow.push_back(n);
- }
- matrix.push_back(currentRow);
- }
- for (int i = col - 1; i >= 0; i--) {
- int r = row;
- for (int j = i; j < col; j++) {
- cout << matrix[--r][j] << ' ';
- if (r == 0) {
- break;
- }
- }
- cout << endl;
- }
- for (int i = row - 2; i >= 0; i--) {
- int r = i;
- for (int j = 0; j < col; j++) {
- cout << matrix[r--][j] << ' ';
- if (r == -1) {
- break;
- }
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement