Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 03 / solutions / exercise 11.cpp
blob: 66a90a904eeff5e9a144dfacd81957f5e302ae14 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>

using namespace std;

int main()
{
	int count;
	cin >> count;

	for (int i = 1; i <= count; i++)
	{
		if (i % 2 != 0)
		{
			for (int j = 1 + ((i - 1) * count); j <= i * count; j++)
			{
				cout << j << " ";
			}
		}
		else
		{
			for (int j = i * count; j > (i - 1) * count; j--)
			{
				cout << j << " ";
			}
		}
		cout << endl;
	}
}