#include<iostream>
#include"stdafx.h"
using namespace std;
void swap (int&a,int&b){
int temp=a;
a=b;
b=temp;
}
int main(){
int **a;
a=new int*[3];
for(int i=0;i<3;i++)
a[i]=new int[3];
cout<<"输入9个整数作为矩形元素值"<<endl;
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
cin>>a[i][j];
cout<<"初始矩形:"<<endl;
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
cout<<a[i][j]<<' ';
cout<<endl;
}
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
swap(a[i][j],a[j][i]);
cout<<"转置后矩形:"<<endl;
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
cout<<a[i][j]<<' ';
cout<<endl;
}
return 0;
}
#include"stdafx.h"
using namespace std;
void swap (int&a,int&b){
int temp=a;
a=b;
b=temp;
}
int main(){
int **a;
a=new int*[3];
for(int i=0;i<3;i++)
a[i]=new int[3];
cout<<"输入9个整数作为矩形元素值"<<endl;
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
cin>>a[i][j];
cout<<"初始矩形:"<<endl;
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
cout<<a[i][j]<<' ';
cout<<endl;
}
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
swap(a[i][j],a[j][i]);
cout<<"转置后矩形:"<<endl;
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
cout<<a[i][j]<<' ';
cout<<endl;
}
return 0;
}