fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a, b, v[10][10];
  6. cin >> a >> b;
  7. for (int i = 0; i < a; ++i) {
  8. for (int j = 0; j < b; ++j) {
  9. cin >> v[i][j];
  10. cout << v[i][j] << " ";
  11. }
  12. cout << "\n";
  13. }
  14. cout << "\n";
  15. for (int i = 0; i < b; ++i) {
  16. for (int j = 0; j < a; ++j) {
  17. cout << v[j][i] << " ";
  18. }
  19. cout << "\n";
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 5280KB
stdin
2 3
1 4 5
2 6 5
stdout
1 4 5 
2 6 5 

1 2 
4 6 
5 5