Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <time.h>
  4. #include <windows.h>
  5.  
  6. using namespace std;
  7.  
  8. int main(int argc, char** argv) {
  9.  
  10. srand(time(0));
  11. int t[4][5],x=0, s=0, s2=0,k, tt[4];
  12.  
  13. for(int j=0; j<4; j++)
  14. {
  15. for(int i=0; i<5; i++)
  16. {
  17. x=(std::rand() %19) - 9;
  18. t[j][i]=x;
  19. }
  20. }
  21.  
  22. for(int w=0; w<4; w++)
  23. {
  24. for(int k=0; k<5; k++)
  25. {
  26. cout<<t[w][k]<<" ";
  27. s2=s2+t[w][k];
  28. }
  29. cout<<"| Suma wiersza wynosi: "<<s2<<endl;
  30. tt[w]=s2;
  31. s2=0;
  32. }
  33.  
  34. cout<<endl<<"Transpozycja\n\n";
  35.  
  36. for(int w=0; w<5; w++)
  37. {
  38. for(int k=0; k<4; k++)
  39. {
  40. cout<<t[k][w]<<" ";
  41. s=s+t[k][w];
  42. }
  43. cout<<"| Suma wiersza wynosi: "<<s<<endl;
  44. s=0;
  45. }
  46.  
  47. cout<<endl;
  48.  
  49. for(int w=0; w<4; w++)
  50. {
  51. cout<<"Suma "<<w+1<<" kolumny wynosi: "<<tt[w]<<endl;
  52. }
  53.  
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement