Code C-C++: Tìm ma trận chuyển vị trong C++


#include<iostream>
#include<iomanip>
using namespace std;
int M[50][50];
void NhapMaTran(int A[50][50], int n, int m){
for(int i=0;i<n;i++)
for(int j=0;j<m;j++){
cout<<"\n A["<<i<<","<<j<<"]= ";
cin>>A[i][j];
}
}
void InMaTran(int B[50][50], int n,int m){
for(int i=0;i<n;i++){
for(int j=0;j<m;j++)
cout<<setw(3)<<B[i][j]; 
cout<<"\n";

}
}
void ChuyenVi(int F[50][50], int n,int m){
for(int j=0;j<m;j++){
for(int i=0;i<n;i++)
cout<<setw(3)<<F[i][j]; 
cout<<"\n";
}
}
main(){
int r,c;
cout<<"\n So dong = "; cin>>r;
cout<<"\n So cot = "; cin>>c;
NhapMaTran(M,r,c);
cout<<"\n Ma tran vua nhap: \n";
InMaTran(M,r,c);
cout<<"Ma tran chuyen vi: \n";
ChuyenVi(M,r,c);
}
Tag: C, C++, ma trận, mảng 2 chiều, mảng hai chiều, ma trận chuyển vị, array

Related Posts
Previous
« Prev Post