DECLARE SUB writeln ()
DIM SHARED matrix(1 TO 4, 1 TO 4) AS INTEGER
RANDOMIZE TIMER
DIM a AS STRING

FOR i = 1 TO 4
FOR j = 1 TO 4
    matrix(i, j) = (i - 1) * 4 + j
NEXT j
NEXT i

CLS
FOR t = 1 TO 100
    FOR i = 1 TO 4
    FOR j = 1 TO 4
        IF matrix(i, j) = 16 THEN
3          tmp1 = 1 + INT(RND * 4)
           tmp2 = 1 + INT(RND * 4)
           IF matrix(tmp1, tmp2) = 16 THEN GOTO 3
           matrix(i, j) = matrix(tmp1, tmp2)
           matrix(tmp1, tmp2) = 16
        END IF
    NEXT j
    NEXT i
NEXT t
1
writeln
IF matrix(1, 1) = 1 AND matrix(1, 2) = 2 AND matrix(1, 3) = 3 AND matrix(1, 4) = 4 THEN
IF matrix(2, 1) = 5 AND matrix(2, 2) = 6 AND matrix(2, 3) = 7 AND matrix(2, 4) = 8 THEN
IF matrix(3, 1) = 9 AND matrix(3, 2) = 10 AND matrix(3, 3) = 11 AND matrix(3, 4) = 12 THEN
IF matrix(4, 1) = 13 AND matrix(4, 2) = 14 AND matrix(4, 3) = 15 AND matrix(4, 4) = 16 THEN
CLS
PRINT "๋ ฏฎกฅคจซ!!!"
DO
LOOP UNTIL INKEY$ <> ""
END


END IF
END IF
END IF
END IF

DIM ch AS STRING
DO
ch = INKEY$
IF ch <> "" THEN EXIT DO
LOOP

SELECT CASE ch
     CASE "8"
             FOR i = 1 TO 4
             FOR j = 1 TO 4
             IF matrix(i, j) = 16 AND i <> 4 THEN
                matrix(i, j) = matrix(i + 1, j)
                matrix(i + 1, j) = 16
                GOTO 1
             END IF
             NEXT j
             NEXT i
     CASE "2"
             FOR i = 1 TO 4
             FOR j = 1 TO 4
             IF matrix(i, j) = 16 AND i <> 1 THEN
                matrix(i, j) = matrix(i - 1, j)
                matrix(i - 1, j) = 16
                GOTO 1
             END IF
             NEXT j
             NEXT i
     CASE "4"
             FOR i = 1 TO 4
             FOR j = 1 TO 4
             IF matrix(i, j) = 16 AND j <> 4 THEN
                matrix(i, j) = matrix(i, j + 1)
                matrix(i, j + 1) = 16
                GOTO 1
             END IF
             NEXT j
             NEXT i
     CASE "6"
             FOR i = 1 TO 4
             FOR j = 1 TO 4
             IF matrix(i, j) = 16 AND j <> 1 THEN
                matrix(i, j) = matrix(i, j - 1)
                matrix(i, j - 1) = 16
                GOTO 1
             END IF
             NEXT j
             NEXT i
     CASE CHR$(27)
        END
END SELECT
GOTO 1


SUB writeln
DIM outmatrix(1 TO 4, 1 TO 4) AS STRING
CLS
FOR i = 1 TO 4
FOR j = 1 TO 4
    SELECT CASE matrix(i, j)
       CASE 1
        outmatrix(i, j) = "01"
       CASE 2
        outmatrix(i, j) = "02"
       CASE 3
         outmatrix(i, j) = "03"
       CASE 4
         outmatrix(i, j) = "04"
       CASE 5
         outmatrix(i, j) = "05"
       CASE 6
         outmatrix(i, j) = "06"
       CASE 7
         outmatrix(i, j) = "07"
       CASE 8
         outmatrix(i, j) = "08"
       CASE 9
         outmatrix(i, j) = "09"
       CASE 10
         outmatrix(i, j) = "10"
       CASE 11
         outmatrix(i, j) = "11"
       CASE 12
         outmatrix(i, j) = "12"
       CASE 13
         outmatrix(i, j) = "13"
       CASE 14
         outmatrix(i, j) = "14"
       CASE 15
         outmatrix(i, j) = "15"
       CASE 16
         outmatrix(i, j) = "  "
       END SELECT
NEXT j
NEXT i

PRINT "ษออออหออออหออออหออออป"

PRINT "บ "; outmatrix(1, 1); " บ "; outmatrix(1, 2); " บ "; outmatrix(1, 3); " บ "; outmatrix(1, 4); " บ"
PRINT "ฬออออฮออออฮออออฮออออน"
PRINT "บ "; outmatrix(2, 1); " บ "; outmatrix(2, 2); " บ "; outmatrix(2, 3); " บ "; outmatrix(2, 4); " บ"
PRINT "ฬออออฮออออฮออออฮออออน"
PRINT "บ "; outmatrix(3, 1); " บ "; outmatrix(3, 2); " บ "; outmatrix(3, 3); " บ "; outmatrix(3, 4); " บ"
PRINT "ฬออออฮออออฮออออฮออออน"
PRINT "บ "; outmatrix(4, 1); " บ "; outmatrix(4, 2); " บ "; outmatrix(4, 3); " บ "; outmatrix(4, 4); " บ"
PRINT "ศออออสออออสออออสออออผ"
FOR h = 1 TO 23
  LOCATE h, 23
  PRINT "ณ"
NEXT h
FOR h = 1 TO 23
  LOCATE 10, h
  PRINT "ฤ"
NEXT h
LOCATE 10, 23
PRINT "ด"
PRINT "    -     8"
PRINT "    -     2"
PRINT "<-   -     4"
PRINT "->   -     6"
LOCATE 2, 25
PRINT "๏โญ ่ชจ - ฏเฎแโ ๏ จฃเ ."
LOCATE 3, 25
PRINT "ฌ๋แซ จฃเ๋ ข โฎฌ ็โฎก๋ เ แแโ ขจโ์ ็จแซ  ฏฎ ฏฎเ๏คชใ."
LOCATE 5, 25
PRINT "ฎแโ ขจโฅซ์  - ฅเๅฎงจญ จโ ซจฉ จชโฎเฎขจ็"
LOCATE 6, 25
PRINT " ญโฅเญฅโฅ จงขฅแโฅญ ช ช W!W!W!"
LOCATE 7, 25
PRINT "E-mail: fotolux@zaural.ru; liceist2000@mail.ru"

END SUB

