1154:0 starting point learning algorithm 61--matrix transpose time limit:1 Sec Memory limit:64 MB 64bit IO Format:%lld
submitted:1324 accepted:698
[Submit] [Status] [Web Board] Description
You are now asked to transpose a matrix column and output, noting that the number of rows and columns may be different.
Input
Multiple sets of test data, each set of test data first input n and M, indicating the number of rows and columns of the matrix (1 < n,m <= 10)
Then a matrix of n rows m columns
Output
For each set of test data output the matrix after transpose
Sample Input
3 21 23) 45 6
Sample Output
1 3 52) 4 6
Source
0 Starting point Learning algorithm
1#include <stdio.h>2 intMain () {3 intn,m,a[Ten][Ten],b[Ten][Ten];4 while(SCANF ("%d%d", &n,&m)! =EOF) {5 6 for(intI=0; i<n;i++){7 for(intj=0; j<m;j++){8scanf"%d",&a[i][j]);9 }Ten } One A for(intI=0; i<m;i++){ - for(intj=0; j<n;j++){ -b[i][j]=A[j][i]; the } - } - - for(intI=0; i<m;i++){ + for(intj=0; j<n-1; j + +){ -printf"%d", B[i][j]); + } Aprintf"%d\n", b[i][n-1]); at } - } - return 0; -}
1154:0 starting point learning algorithm 61--matrix transpose