减去矩阵
2021-07-07 07:26:56
深夜i
--
--
减
去
矩
阵
用于减去任何阶矩阵的 C 代码。 该程序找出两个矩阵的对应元素之间的差异,然后打印结果矩阵。
C程序
#include <stdio.h>
int main()
{
int m, n, c, d, first[10][10], second[10][10], difference[10][10];
printf("Enter the number of rows and columns of matrix\n");
scanf("%d%d", &m, &n);
printf("Enter the elements of first matrix\n");
for (c = 0; c < m; c++)
for (d = 0 ; d < n; d++)
scanf("%d", &first[c][d]);
printf("Enter the elements of second matrix\n");
for (c = 0; c < m; c++)
for (d = 0; d < n; d++)
scanf("%d", &second[c][d]);
printf("Difference of entered matrices:-\n");
for (c = 0; c < m; c++) {
for (d = 0; d < n; d++) {
difference[c][d] = first[c][d] - second[c][d];
printf("%d\t",difference[c][d]);
}
printf("\n");
}
return 0;
}
下载减法矩阵程序。
程序输出:
上一篇:
idea打包java可执行jar包
下一篇:
C中矩阵的转置
评论区