# Sdut 3347 Data Structure Experiment array three: Quick transpose

Source: Internet
Author: User

Array of data structure experiment three: Quick transpose time limit:1000ms Memory limit:65536kbsubmit Statisticproblem Description

The transpose operation is one of the simplest matrix operations, for a m*n matrix m (1 = < M < = 10000,1 = < N < = 10000), its transpose matrix T is a n*m matrix, and T (i, J) =m (J, i). Obviously, the transpose of a sparse matrix is still a sparse matrix. Your task is to calculate the matrix and output it for the sparse matrix (m, n < = 10000) given a m*n. Matrix M and the transpose matrix T as shown in the example.

Sparse matrix M sparse matrix T

Input

Continuous input of multiple sets of data, the first row of each group of data is three integers mu, nu, tu (tu <= 50), representing the number of rows, columns, and matrices of the sparse matrix, respectively, the rows, column values, and non-0 elements of the non-0 elements of the sparse matrix. A space interval between the same row of data. (The matrix is the main order of the line order)

Output

The Ternary sequential table representation of the sparse matrix after the output transpose.

Example Input
`3 5 51 2 141 5-52 2-73 1 363 4 28`
Example Output
`1 3 362 1 142 2-74 3 285 1-5`
DQE: Fast transpose of the matrix, water.
`1#include <iostream>2#include <cstdio>3 4 using namespacestd;5 6 structTS7 {8     struct{intI,j;inte;} data[10010];//100009     intNu,mu,tu;Ten }; One  A voidZZ (TS F,ts &z) - { -z.tu=f.tu;z.nu=f.mu;z.mu=f.nu;//jscpy the     intnum[10010]={0},cpot[10010]={1}; -     inti; -      for(i=1; i<=f.tu;i++) -     { +num[f.data[i].j]++; -     } +cpot[1]=1; A      for(i=2; i<=z.nu;i++) at     { -cpot[i]=cpot[i-1]+num[i-1]; -     } -      for(i=1; i<=z.tu;i++) -     { -         intZi=F.DATA[I].J; in         intzn=Cpot[zi]; -Z.data[zn].e=f.data[i].e; toZ.data[zn].i=F.DATA[I].J; +z.data[zn].j=f.data[i].i; -cpot[zi]++; the     } * } \$ Panax Notoginseng intMain () - { the TS f,z; +      while(SCANF (" %d%d%d", &f.nu,&f.mu,&f.tu)! =EOF) A     { the         inti; +          for(i=1; i<=f.tu;i++)//inch -         { \$scanf" %d%d%d",&f.data[i].i,&f.data[i].j,&f.data[i].e); \$         } -  - ZZ (f,z); the  -          for(i=1; i<=z.tu;i++)// outWuyi         { theprintf"%d%d%d\n", Z.DATA[I].I,Z.DATA[I].J,Z.DATA[I].E); -         } Wu     } -     return 0; About } \$  - /*************************************************** - User Name: * * * - result:accepted A Take time:0ms + Take memory:464kb the Submit time:2016-10-12 16:19:44 - ****************************************************/`

Sdut 3347 Data Structure Experiment array three: Quick transpose

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.