Вычислить элементы матрицы а=а(i,j), если a(i,j)=b(i,j) при Ib(i,j)I>Ic(i,j) и a(i,j)=c(i,j) при Ib(i,j)I<=Ic(i,j) - QBasic(Бейсик)

b=(2.5 -3.0 6.2)
(-0.1 4.2 2.8)
(2.0 7.5 -1.8)

с=(-2.0 2.3 -7.1)
(0.8 3.6 -5.6)
(3.0 6.0 4.0)
DATA 2.5,-3.0,6.2,-0.1,4.2,2.8,2.0,7.5,-1.8
DATA -2.0,2.3,-7.1,0.8,3.6,-5.6,3.0,6.0,4.0
DIM a(3, 3), b(3, 3), c(3, 3)
PRINT "matrica b"
FOR i = 1 TO 3
    FOR j = 1 TO 3
        READ b(i, j)
        PRINT b(i, j);
    NEXT
    PRINT
NEXT
PRINT "matrica c"
FOR i = 1 TO 3
    FOR j = 1 TO 3
        READ c(i, j)
        PRINT c(i, j);
    NEXT
    PRINT
NEXT
PRINT "matrica a"
FOR i = 1 TO 3
    FOR j = 1 TO 3
        IF ABS(b(i, j)) > ABS(c(i, j)) THEN a(i, j) = b(i, j) ELSE a(i, j) = c(i, j)
        PRINT a(i, j);
    NEXT
    PRINT
NEXT

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

Leave a Comment