Home > Back-end >  Matrix transpose
Matrix transpose

Time:09-23

Write the matrix transpose function, manual input matrix rows and columns,

CodePudding user response:

 # include 
# define m 2
# define n 3
Int main ()
{
int i,j;
Int a [m] [n], [n] [m]. B
Printf (" please input array data \ n ");
for(i=0; i{
for(j=0; j{
The scanf (" % d ", & amp; A [I] [j]);
B [j] [I]=[I] [j];
}
}
for(j=0; j{
for(i=0; i{
Printf (" % d, b [j] [I]);
}
printf("\n");
}
return 0;
}

CodePudding user response:

# include "stdafx. H"
#include
#include
#includeusing namespace std;
# define N 100
The class RectangleZhuan
{
Public:
RectangleZhuan ()
{
Cout<& lt;" You have entered the matrix transformation object, please input matrix order, shall not exceed 100: \ n ";
GetNum ();
GetsRecBass ();


}
~ RectangleZhuan ()
{
Cout<& lt;" Calling the destructor, matrix transformation exit!" }

Void getNum ()
{
Int nw;
cin> Nw.
N=nw;
}
Void getsRecBass ()
{
Cout<& lt;" Please input information for matrix items: \ n ";
for(i=0; ifor(j=0; jcin> A, [I] [j].
Cout<& lt;" You just input the information for: \ n ";
for(i=0; ifor(j=0; j{
If (j + 1) % (n==0)
CoutThe else
Cout
}
for(i=0; ifor(j=i+1; j{
Int temp=a, [I] [j].
A [I] [j]=[j] a [I];
A [j] [I]=temp;
}
Cout<& lt;" After transposed matrix for: \ n ";
for(i=0; ifor(j=0; j{
If (j + 1) % (n==0)
Cout
The else
Cout
}
}




Private:
Int a [N] [N], I, j, N.
};
Void main ()
{
RectangleZhuan r;
} oriented to the code,
  • Related