Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cctype>
- #define EXAMPLE
- using namespace std;
- string acronym(string text);
- int main()
- {
- const int MAX = 20;
- #ifdef EXAMPLE
- int matrix[MAX][MAX] = {{1, 2, 3, 4},
- {5, 6 ,7 ,8},
- {9,10,11,12},
- {13,14,15,16}};
- int n = 4;
- #else
- int matrix[MAX][MAX];
- int n;
- do
- {
- cout << "Enter n: ";
- cin >> n;
- }
- while (n < 1 || n > MAX);
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- {
- cin >> matrix[i][j];
- }
- }
- #endif
- for (int i = 0; i < n; i++)
- {
- for (int row = i, col = 0; row >= 0 ; row--, col++)
- {
- cout << matrix[row][col] << " ";
- }
- cout << endl;
- }
- for (int i = 1; i < n ; i++)
- {
- for (int col = i, row = n - 1; col < n; row--, col++)
- {
- cout << matrix[row][col] << " ";
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement