Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = 1;
- while (x <= n / 2) { // n - dimensiunea
- for (j = x; j <= n - x; j ++)
- a[x][j] = ++k;
- for (i = x; i <= n - x; i ++)
- a[i][n - x + 1] = ++k;
- for (j = n - x + 1; j > x; j --)
- a[n - x + 1][j] = ++k;
- for (i = n - x + 1; i > x; i --)
- a[i][x] = ++k;
- x ++;
- }
- if (n & 1)
- a[n / 2 + 1][n / 2 + 1] = ++k;
Advertisement
Add Comment
Please, Sign In to add comment