// 键盘输入矩阵并打印结果
#include<stdio.h>
#include<string.h>
void main()
{
// 定义int类型的 2*2的二维数组
int A[2][2];
// 定义循环计数器变量
int icount, jcount;
// 利用双重循环遍历输出矩阵A
printf("Please input the matrix A:\n");
for (icount=0;icount<2;icount++)
{
for (jcount=0;jcount<2;jcount++)
{
scanf("%d",&A[icount][jcount]);
}
}
// 利用双重循环遍历输出矩阵B
printf("The Matrix A is:\n");
for (icount=0;icount<2;icount++)
{
for (jcount=0;jcount<2;jcount++)
{
printf("%8d",A[icount][jcount]);
}
printf("\n");
}
}
结果: