package no402; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[][] a = new int[n][n]; int di = 0, dj = 1; int ci = 0, cj = 0; for(int i=1;i<=n*n;i++) { a[ci][cj] = i; int ni = ci + di; int nj = cj + dj; if (ni < 0 || ni >= n || nj < 0 || nj >= n || a[ni][nj] != 0) { int temp = di; di = dj; dj = -temp; } ci = ci + di; cj = cj + dj; } for(int i=0;i 0) { System.out.print(' '); } System.out.print(String.format("%03d", a[i][j])); } System.out.println(); } } }