INPUT "vvedite razmer N ", n
x = 0
y = 1
num = 1
dlina = n
shag = 1
DO WHILE dlina <> 0
i = 0
DO WHILE i <> dlina
x = x + shag
a(y, x) = num
num = num + 1
i = i + 1
LOOP
i = 0
dlina = dlina - 1
DO WHILE i <> dlina
y = y + shag
a(y, x) = num
num = num + 1
i = i + 1
LOOP
shag = shag * (-1)
LOOP
OPEN "output.txt" FOR OUTPUT AS #1
FOR i = 1 TO n
FOR j = 1 TO n
PRINT #1, a(i, j);
NEXT
PRINT #1, ""
NEXT
CLOSE
Тестирование выполнено в программе QB64 ( Скачать )