#include<stdio.h>
void print(int arr[2][2])
{
int m = 0;
int n = 0;
for (m = 0; m < 2; m++)
{
for (n = 0; n < 2; n++)
{
printf("%2d ", arr[m][n]);
}
printf("\n");
}
}
int main()
{
int a, b, c,d;
int arr1[2][2] = { 0 };
int arr2[2][2] = { 0 };
int arr3[2][2] = { 0 };
for (c = 0; c < 2; c++)
{
for (d = 0; d < 2; d++)
{
scanf("%d", &arr1[c][d]);
}
}
printf("矩阵一\n");
print(arr1);
for (c = 0; c < 2; c++)
{
for (d = 0; d < 2; d++)
{
scanf("%d", &arr2[c][d]);
}
}
printf("矩阵二\n");
print(arr2);
printf("总和\n");
for (c = 0; c < 2; c++)
{
for (d = 0; d < 2; d++)
{
printf("%2d ", arr1[c][d] + arr2[c][d]);
}
printf("\n");
}
}文章来源地址https://www.toymoban.com/news/detail-758196.html
文章来源:https://www.toymoban.com/news/detail-758196.html
到了这里,关于c语言--矩阵输出的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!