Вычислить сумму двух заданных матриц размером 3*3- QBasic(Бейсик)

CLS
n=3
DIM a(n,n)
DIM b(n,n)
RANDOMIZE TIMER
FOR i=1 TO n
 FOR j=1 TO n
  a(i,j)=INT(RND*101)-50
  b(i,j)=INT(RND*101)-50
 NEXT j
NEXT i
PRINT "Matrica A"
FOR i=1 TO n
 FOR j=1 TO n
  PRINT a(i,j);
 NEXT j
 PRINT
NEXT i
PRINT
PRINT "Matrica B"
FOR i=1 TO n
 FOR j=1 TO n
  PRINT b(i,j);
 NEXT j
 PRINT
NEXT i
PRINT
DIM s(n,n)
FOR i=1 TO n
 FOR j=1 TO n
  s(i,j)=a(i,j)+b(i,j)
 NEXT j
NEXT i
PRINT "Summa matric"
FOR i=1 TO n
 FOR j=1 TO n
  PRINT s(i,j);
 NEXT j
 PRINT
NEXT i

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

Leave a Comment