Сумма и произведение нечётных отрицательных элементов матрицы, удовлетворяющих условию |Ai,j|< i - QBasic(Бейсик)

CLS
RANDOMIZE TIMER
INPUT "введите два числа", n, m
DIM a(n, m)
 
FOR i = 0 TO n - 1
FOR j = 0 TO m - 1
a(i, j) = INT((-4 + (1)) * RND(1)): PRINT a(i, j),
NEXT j
PRINT
NEXT i
PRINT
 
s = 0
 
FOR i = 0 TO n - 1
FOR j = 0 TO m - 1
IF a(i, j) < 0 AND (a(i, j) / 2) = INT(a(i, j) / 2) AND (ABS(a(i, j))) < i THEN s = s + a(i, j)
NEXT j
PRINT
NEXT i
 
PRINT "s=", s;
PRINT
 
w = 1
 
FOR i = 0 TO n - 1
FOR j = 0 TO m - 1
IF a(i, j) < 0 AND (a(i, j) / 2) = INT(a(i, j) / 2) AND (ABS(a(i, j))) < i THEN w = w * a(i, j)
NEXT j
NEXT i
 
PRINT "w=", w;
END

Leave a Comment