首页 > 编程 > C++ > 正文

11、C++键盘输入矩阵并打印结果

2019-11-08 01:00:28
字体:
来源:转载
供稿:网友
// 键盘输入矩阵并打印结果#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"); } }

结果: 这里写图片描述


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选