Подсчитать и вывести сумму положительных элементов в каждом столбце полученного массива — QBasic(Бейсик)

CLS
ny = 10: nx = 5
DIM a(ny, nx), s(nx)
FOR y = 1 TO ny: FOR x = 1 TO nx
        PRINT "vvedite a("; y; ","; x; ")"
        INPUT a(y, x)
        b(y, x) = a(y, x)
NEXT: NEXT
FOR y = 1 TO ny: FOR x = 1 TO nx
        IF a(y, x) = 0 THEN b(y, x) = 1
        IF a(y, x) < 0 THEN b(y, x) = 0
NEXT: NEXT
FOR x = 1 TO nx: FOR y = 1 TO ny
        s(x) = s(x) + b(y, x)
NEXT: NEXT
CLS
PRINT "matrica", "", "new matrica"
FOR y = 1 TO ny
    FOR x = 1 TO nx
        PRINT a(y, x);
    NEXT
    PRINT "",
    FOR x = 1 TO nx
        PRINT b(y, x);
    NEXT
    PRINT
NEXT
PRINT "", "", "summa"
FOR x = 1 TO nx
    PRINT "", "", "stolbec"; x; "summa"; s(x)
NEXT

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

Leave a Comment