В заданной матрице A(n,m) нужно упорядочить элементы каждого ряда по возрастанию

code: #basic
CLS
DIM i AS INTEGER, j AS INTEGER, n AS INTEGER, m AS INTEGER
DIM k AS INTEGER
 
INPUT "Vvedite kolvo strok-->"; n
INPUT "Vvedite kolvo stolbcov-->"; m
DIM a(n, m) AS INTEGER
RANDOMIZE TIMER
 
PRINT : PRINT "Ishodniy massiv: "
FOR i = 1 TO n
        FOR j = 1 TO m
                a(i, j) = INT(RND * 89) + 10
                PRINT a(i, j);
        NEXT j: PRINT
NEXT i: PRINT
 
 
FOR i = 1 TO n
        FOR k = 1 TO m
        FOR j = 1 TO m - 1
                        IF a(i, j) > a(i, j + 1) THEN SWAP a(i, j), a(i, j + 1)
                NEXT j
        NEXT k
NEXT i
 
PRINT : PRINT "Polucheniy massiv: "
FOR i = 1 TO n
        FOR j = 1 TO m
                PRINT a(i, j);
        NEXT j: PRINT
NEXT i
Поделиться:

Похожие статьи: