fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. using namespace std;
  5.  
  6. const int N=4;
  7. const int M=5;
  8.  
  9. int main() {
  10.  
  11. srand(time(NULL));
  12.  
  13. int tab[N][M];
  14.  
  15. cout << "Przed transpozycja: " << endl;
  16. for (int i=0; i<N; i++)
  17. {
  18. for (int j=0; j<M; j++)
  19. {
  20. //wylosujmy liczby z zakresu [-10, 100]
  21. tab[i][j]= rand()%111-10;
  22. cout << tab[i][j] << " ";
  23. }
  24. cout << endl;
  25. }
  26.  
  27. cout << "Po transpozycji: " << endl;
  28. for (int j=0; j<M; j++)
  29. {
  30. for (int i=0;i<N; i++)
  31. cout << tab[i][j] << " ";
  32. cout << endl;
  33. }
  34.  
  35.  
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
Przed transpozycja: 
63 7 7 33 54 
97 10 83 66 53 
52 63 55 99 -5 
18 22 32 -10 82 
Po transpozycji: 
63 97 52 18 
7 10 63 22 
7 83 55 32 
33 66 99 -10 
54 53 -5 82