#include<iostream>
using namespace std;
int main()
{
int a, b;
cout<<"请输入矩阵的行数和列数:"<<endl;
while (cin >>a>>b)
{
int **array = new int*[a];
for (int i = 0; i < b; i++)
{
array[i] = new int[b];
}
cout<<"请输入矩阵的值,空格隔开:"<<endl;
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
{
cin >> array[i][j];
}
}
cout<<"实矩阵A:"<<endl;
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
{ cout<< array[i][j]<<"\t"; }
cout<<endl;
}
}
return 0;
}
【C/C++中动态分配二维数组】输入输出二位数组
最新推荐文章于 2024-03-13 20:04:21 发布