fork download
  1. #include <iostream>
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. // your code goes here
  7. int rows,cols; cin>>rows>>cols;
  8. vector<vector<int>>arr(rows,vector<int>(cols));
  9. for(int i =0;i<rows;i++){
  10. for(int j =0;j<cols;j++){
  11. cin>>arr[i][j];
  12. }
  13. }
  14. for(int i =0;i<rows;i++){
  15. for(int j =0;j<cols;j++){
  16. if(i<j) swap(arr[i][j],arr[j][i]);
  17. }
  18. }
  19. for(int i =0;i<rows;i++){
  20. for(int j =0;j<cols;j++){
  21. cout<<arr[i][j];
  22. }
  23. cout<<endl;
  24. }
  25.  
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0.01s 5292KB
stdin
3 3 
1 2 3
4 5 6
7 8 9
stdout
147
258
369