有两个矩阵A1,A2,编写一个程序,实现这两个矩阵的乘积。
- #include <stdio.h>
-
-
int main(int argc, char *argv[])
-
{
-
int A[2][3] = {{1,2,3},{4,5,6}};
-
int B[3][4] = {{1,0,2,3},{4,1,5,6},{6,8,9,0}};
-
int C[2][4] = {{0,0,0,0},{0,0,0,0}};
-
-
int i,j,k;
-
for(i = 0; i < 2; i++)
-
for(j = 0; j < 4; j++)
-
for(k = 0; k < 3; k++)
-
C[i][j] += A[i][k] * B[k][j];
-
-
printf("the result is\n");
-
for(i = 0; i < 2; i++)
-
{
-
for(j = 0; j < 4; j++)
-
{
-
printf("%d ",C[i][j]);
-
}
-
printf("\n");
-
}
-
-
return 0;
-
}
阅读(2093) | 评论(0) | 转发(0) |