fork download
  1. //Q74. Find the transpose of a matrix.
  2. #include <stdio.h>
  3. int main() {
  4. int r,c,a[10][10],i,j;
  5. scanf("%d%d",&r,&c);
  6. for(i=0;i<r;i++)
  7. for(j=0;j<c;j++)
  8. scanf("%d",&a[i][j]);
  9. for(j=0;j<c;j++){
  10. for(i=0;i<r;i++)
  11. printf("%d ",a[i][j]);
  12. printf("\n");
  13. }
  14. }
  15.  
  16.  
Success #stdin #stdout 0s 5320KB
stdin
2 3 
1 2 3 
4 5 6
stdout
1 4 
2 5 
3 6