📄 transpose.cpp
字号:
// Transpose.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "Transpose.h"
int main(int argc, char* argv[])
{
TSMatrix M,T;
int mu,nu,t=0,i,j,n;
cout<<"===========================Transpose Arithmetic========================"<<endl;
cout<<"Please Input mu,nu"<<endl;
cout<<"For exp: 3 3"<<endl;
cin>>mu>>nu;
cout<<"OK,then Input the data for the SMatrix"<<endl;
M.nu=nu;
M.mu=mu;
for(i=1,n=1;i<=mu;i++)
for(j=1;j<=nu;j++)
{ M.data[n].i=i;
M.data[n].j=j;
cout<<"SMatrix"<<"["<<n<<"]"<<": ";
cin>>M.data[n].e;
if(M.data[n].e!=0) t++;
n++;
}//input data
M.tu=t;
for( i=1,n=1;i<=nu;i++)
for(j=1;j<=mu;j++)
{ T.data[n].i=i;
T.data[n].j=j;
T.data[n].e=0;
n++;
}//init T
cout<<"Your Init Matrix:"<<endl;
for(i=1,n=1;i<=mu;i++)
{for( j=1;j<=nu;j++)
{
cout<<M.data[n].e<<"\t";
n++;
}
cout<<""<<endl;
}//show the init matrix
cout<<"The TransposeSMatrix:"<<endl;
T.mu=M.nu;
T.nu=M.mu;
T.tu=M.tu;
if(T.tu)
{int q=1;
for(int col=1;col<=M.nu;++col)
for(int p=1;p<=M.tu;++p)
if(M.data[p].j==col){
T.data[q].i=M.data[p].j;
T.data[q].j=M.data[p].i;
T.data[q].e=M.data[p].e;
++q;}
}//Transpose
for(i=1,n=1;i<=T.mu;i++)
{for( j=1;j<=T.nu;j++)
{
cout<<T.data[n].e<<"\t";
n++;
}
cout<<""<<endl;
}//show the finished matrix
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -