-
Notifications
You must be signed in to change notification settings - Fork 0
/
Matran1.c
39 lines (37 loc) · 1.04 KB
/
Matran1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdio.h>
const MAX = 100;
void InputMatrix(int A[][MAX], int m, int n){
int i, j;
for (i = 0; i < m; i++)
for (j = 0; j < n; j++){
printf("PT[%d][%d] = ", i, j);
scanf("%d", &A[i][j]);
}
}
void OutputMatrix(int A[][MAX], int m, int n){
int i, j;
for (i = 0; i < m; i++){
for (j = 0; j < n; j++)
printf("%4d", A[i][j]);
printf("\n");
}
}
int main(){
int A[MAX][MAX], B[MAX][MAX], C[MAX][MAX], m, l, n, i, j, k;
printf("Nhap m = "); scanf("%d", &m);
printf("Nhap l = "); scanf("%d", &l);
printf("Nhap n = "); scanf("%d", &n);
puts("Nhap ma tran A:");; InputMatrix(A, m, l);
puts("Nhap ma tran B:");; InputMatrix(B, l, n);
puts("Ma tran C = A*B:");
for (i = 0; i < m; i++){
for (j = 0; j < n; j++){
C[i][j] = 0;
for (k = 0; k < 1; k++)
C[i][j] += A[i][k]*B[k][j];
printf("%4d", C[i][j]);
}
printf("\n");
}
return 0;
}