Home > Back-end >  Matrix multiplication && input format
Matrix multiplication && input format

Time:09-29

Using the matrix multiplication formula cij=aik * BKJ, programming calculation and output m * n order matrix A and n * m order the products of the matrix B, among them, the m and n input from the keyboard, value is not more than 6 m and n, otherwise prompt the user to input, if the input illegal characters may also prompt the user to input, that according to the following function prototype program:

Function:/* function calculation m * n order matrix A and n * m order the products of the matrix B, results in A two-dimensional array c */

Void MultiplyMatrix (int a [ROW] [COL], int b [COL] [ROW], int ROW (ROW), c int m, int n);

/* function function: output the elements in the matrix a * m * m order/

Void PrintMatrix (int a [ROW] [ROW], int m);



* * enter the m and n Input message: "Input m, n:"

* * enter m and n input statement:

Cin & gt;> m;

Cin. Ignore (1);

Cin & gt;> n;


* * input matrix elements of the input message (matrix a, for example) :

Cout & lt; <"Input" & lt;
Matrix element according to the line of the input, separated by a space,



* * output message: "the Results: \ n
"
* * output format:

Setw (6)



Application example:

Input m, n: 7, a

Input m, n: 7, 8

Input m, n: 2, 3

2 * 3 Input matrix a:

1 2 3

4 5 6

The Input matrix of 3 * 2 b:

1
2
3, 4,

5 6

Results:

22 to 28

49 64

Note:

(1) cannot use Pointers, structures, sharing, file, goto, programming enumerated types,

(2) using the standard C language programming, all variables must be defined before the first executable statement,
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Seek help from bosses
  • Related