It is best to use tc2.0 in Chinese
# Include <stdio. h>
# Define N 10
Typedef struct {
Int I, j;
Int e;
} TsMatrix;
Typedef struct {
TsMatrix data [N];/* the maximum length is N */
Int mu, nu, tu;
} TSMatrix;
Int FastTransposeSMatrix (TSMatrix M, TSMatrix * T)
{
Int col, p, q, t;
Int num [N], cpot [N];
T-> mu = M. nu; T-> nu = M. mu; T-> tu = M. tu;
If (T-> tu)
{
For (col = 1; col <= M. nu; ++ col) num [col] = 0;
For (t = 1; t <= M. tu; ++ t) ++ num [M. data [t]. j];
Cpot [1] = 1;
For (col = 2; col <= M. nu; ++ col)
Cpot [col] = cpot [col-1] + num [col-1];
For (p = 1; p <= M. tu; ++ p)
{Col = M. data [p]. j; q = cpot [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; ++ cpot [col];
}
}
}
Void printM (TSMatrix * M)
{
Int p, q; int t = 1;
For (p = 1; p <= M-> mu; p ++)
{
For (q = 1; q <= M-> nu; q ++)
{If (M-> data [t]. I = p & M-> data [t]. j = q)
{Printf ("% d", M-> data [t]. e); t ++ ;}
Else printf ("0 ");}
Printf ("n");} printf ("nn ");
}
Void main ()
{
TSMatrix A, T; int k;
Printf ("Enter the size of the matrix :");
Printf ("its row:"); scanf ("% d", & A. mu );
Printf ("its columns:"); scanf ("% d", & A. nu );
Printf ("enter A length not greater than 10 and not 0:"); scanf ("% d", & A. tu );
For (k = 1; k <= A. tu; k ++)
{Printf ("Enter the number of % d: n", k );
Printf ("its row location:"); scanf ("% d", & A. data [k]. I );
Printf ("its column location:"); scanf ("% d", & A. data [k]. j );
Printf ("its value:"); scanf ("% d", & A. data [k]. e );
}
Printf ("n original matrix: n ");
PrintM (& );
FastTransposeSMatrix (A, & T );
Printf ("transposed matrix: n ");
PrintM (& T );
}
<