Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void solve() {
- int magic[4][4] = {{ 8, 9, 1, 13},
- { 3, 12, 7, 5},
- { 0, 2, 4, 11},
- { 6, 10, 15, 14}};
- int n, N;
- cin >> n;
- N = n / 4;
- int square[n + 1][n + 1];
- for (int i = 0; i < n; i += 4) {
- for (int j = 0; j < n; j += 4) {
- int I = i / 4;
- int J = j / 4;
- for (int k = 0; k < 4; ++k) {
- for (int l = 0; l < 4; ++l) {
- square[i + k][j + l] = 16 * (I * N + J) + magic[k][l];
- }
- }
- }
- }
- for (int i = 0; i < n; ++i) {
- for (int j = 0; j < n; ++j) {
- cout << square[i][j] << ' ';
- }
- cout << '\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement