Sa se scrie un program care calculeaza transpusa unei matrici An*m

#include <iostream.h>
void main(void)
{
int n,m,i,j,a[30][30],b[30][30];
cout<<"Dati dimensiunile matricei "<<endl;
cout<<"Dati numarul de linii n = ";cin>>n;
cout<<"Dati numarul de coloane m = ";cin>>m;
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
{
cout<<"a["<<i<<","<<j<<"]= ";
cin>>a[i][j];
}
cout<<"Elementele matricei A sunt: "<<endl;
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
cout<<a[i][j]<<" ";
cout<<endl;
}
for(i=1;i<=n;i++)
for(j=1;i<=m;i++)
b[j][i]=a[i][j];
cout<<"Matricea transpusa este "<<endl;
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
cout<<b[i][j]<<" ";
cout<<endl;
}
}