//刚写的code,测试通过,如果有疑问,欢迎交流
#include
#include
#include
using namespace std;
#define N 4
#define M 5
int main(){
srand(time(0));
int src[M][N], tar[N][M];
int i,j;
for(i = 0; ifor(j = 0; j src[i][j] = rand()%100;
//这里是随机生成的数
//如果是输入的可以修改为
//cin>>src[i][j];
for(i = 0; ifor(j = 0; j tar[j][i] = src[i][j];
for(i = 0; ifor(j = 0; j cout< cout< }
cout<
for(i = 0; ifor(j = 0; j cout< cout< }
return 0;
}
#include
#include
#include
#include
using namespace std;
const int maxn =100;
int a[maxn][maxn];
int b[maxn][maxn];
int main(void)
{
int m,n;
int i,j,t;
cout<<"请输入矩阵行数 列数:\n";
while(scanf("%d%d",&m,&n)==2)
{
cout<<"请按行依次输入矩阵元素:"<for ( i = 0; i < m; i++)
for ( j = 0; j < n; j++)
cin>>a[i][j];
cout<<"\n转置前的矩阵:\n";
for ( i = 0; i < m; i++)
{
for ( j = 0; j < n; j++)
cout<cout<}
for ( i = 0; i < m; i++)
for ( j = 0; j < n; j++)
b[j][i] =a[i][j];
cout<<"\n转置后的矩阵:\n";
for ( i = 0; i < n; i++)
{
for ( j = 0; j < m; j++)
cout<cout<}
cout<<"请输入矩阵行数 列数:\n";
}
return 0;
}
#include
using namespace std;
int main()
{
int m,n,i,j;
cin>>m>>n;
int a[m][n];
for(i=0;ifor(j=0;j cin>>a[i][j];
for(i=0;i{
for(j=0;jcout< cout< }
for(i=0;i{
for(j=0;jcout< cout< }
system("pause");
return 0;
}