Найти сумму всех положительных и отрицательных элементов массива В(4,3)- QBasic(Бейсик)

CLS
ny = 4: nx = 3
DIM b(ny, nx)
FOR y = 1 TO ny
    FOR x = 1 TO nx
        PRINT "vvedite element"; y; "stroka"; x; "stolbec"
        INPUT b(y, x)
    NEXT
NEXT
FOR y = 1 TO ny
    FOR x = 1 TO nx
        IF b(y, x) > 0 THEN s1 = s1 + b(y, x) ELSE s2 = s2 + b(y, x)
    NEXT
NEXT
PRINT "matrica"
FOR y = 1 TO ny
    FOR x = 1 TO nx
        PRINT b(y, x);
    NEXT
    PRINT
NEXT
PRINT
PRINT "summa polozhitelnyh = "; s1
PRINT "summa otrichatelnyh =  "; s2

Тестирование выполнено в программе QB64 ( Скачать )

Leave a Comment