Создать программу для перемножения двух матриц и вывода на экран результирующей матрицы

code: #basic
CLS
PRINT "Multiplying matrices"
INPUT "Enter the dimension of the matrices A and B"; n%
PRINT "Enter the matrix A"
FOR i% = 1 TO n%
        FOR j% = 1 TO n%
                PRINT "a("; i%, j%; ")=": INPUT a(i%, j%)
        NEXT j%
NEXT i%
PRINT "The matrix A introduced"
PRINT "__________________________________"
PRINT ""
PRINT "Enter the matrix B"
FOR i% = 1 TO n%
        FOR j% = 1 TO n%
                PRINT "b("; i%, j%; ")=": INPUT b(i%, j%)
        NEXT j%
NEXT i%
PRINT "The matrix B introduced"
PRINT "__________________________________"
PRINT ""
FOR i% = 1 TO n%
        FOR j% = 1 TO n%
                FOR k% = 1 TO n%
                c(i%, j%) = c(i%, j%) + a(i%, k%) * b(k%, j%)
                NEXT k%
        NEXT j%
NEXT i%
PRINT "The product A * B"
FOR i% = 1 TO n%
        FOR j% = 1 TO n%
        PRINT c(i%, j%);
        NEXT j%
        PRINT
NEXT i%
END

автор: sentinel

Поделиться:

Похожие статьи: