Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- const int MAX = 20;
- 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];
- }
- }
- for (int j = 0; j < n; j++)
- {
- for (int i = 0; i < j; i++)
- {
- cout << matrix[n - i - 1][j] << " ";
- }
- for (int i = j; i >= 0; i--)
- {
- cout << matrix[n - 1 - j][i] << " ";
- }
- cout << endl;
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement