Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- int rows = 1;
- for (int i = 1; i <= n * n; i+=n)
- {
- if (rows % 2 != 0)
- {
- for (int p = i; p <= i+n-1; p++)
- {
- cout << p;
- if (p == i+n-1)
- {
- cout << endl;
- rows++;
- }
- }
- }
- else
- {
- for (int q = i+n-1; q >= i; q--)
- {
- cout << q;
- if (q == i)
- {
- cout << endl;
- rows++;
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement