|
zadach165.BAS |
|
{* Задача165 *}REM basic ' Вводится n, надо получить матрицу n*n, заполненную по диагоналям, например:' 1 2 6' 3 5 7' 4 8 9CLS
INPUT "vvedite n"; n
Dim a(n, n)
Do
i = i + 1
If (i And 1) = 0 Then c = 1: Else c = -1
Select Case i
Case Is n
If (i And 1) = 0 Then a = a + 1 Else b = b + 1
End Select
For y = a To b Step c
If (i And 1) = 0 Then d = b - y + a Else d = d + 1
For x = d To d
r = r + 1
a(y, x) = r
Next
Next
SWAP a, b
Loop Until i = 2 * n
For y = 1 To n
For x = 1 To n
LOCATE y + 1, x * 4
PRINT a(y, x);
Next
PRINT
Next
End
|