标签:loading tip for form show include load put span
求4行3列矩阵和3行4列矩阵的乘积。各构成元素的值从键盘输入。
1、
#include <stdio.h>
int main(void)
{
int i, j, k, a[4][3], b[3][4], c[4][4] = {0};
puts("input the elements of 4 row 3 col array.");
for(i = 0; i < 4; i++)
{
for(j = 0; j < 3; j++)
{
printf("a[%d][%d] = ", i, j); scanf("%d", &a[i][j]);
}
}
puts("show the matrix form of 4 row 3 col array.");
for(i = 0; i < 4; i++)
{
for(j = 0; j < 3; j++)
{
printf("%4d", a[i][j]);
}
putchar(‘\n‘);
}
putchar(‘\n‘);
puts("input the elements of 3 row 4 col array.");
for(i = 0; i < 3; i++)
{
for(j = 0; j < 4; j++)
{
printf("b[%d][%d] = ", i, j); scanf("%d", &b[i][j]);
}
}
puts("show the matrix for of 3 row 4 col ayyay.");
for(i = 0; i < 3; i++)
{
for(j = 0; j < 4; j++)
{
printf("%4d", b[i][j]);
}
putchar(‘\n‘);
}
putchar(‘\n‘);
puts("calculate the multiply of arraies.");
for(i = 0; i < 4; i++)
{
for(j = 0; j < 4; j++)
{
for(k = 0; k < 3; k++)
{
c[i][j] += a[i][k] * b[k][j];
}
}
}
puts("show the multiply result.");
for(i = 0; i < 4; i++)
{
for(j = 0; j < 4; j++)
{
printf("%4d", c[i][j]);
}
putchar(‘\n‘);
}
return 0;
}
c语言 5-10 求4行3列矩阵和3行4列矩阵的乘积。各构成元素的值从键盘输入。
标签:loading tip for form show include load put span
原文地址:https://www.cnblogs.com/liujiaxin2018/p/14723543.html