Facebook
From Mungo Human, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 193
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <windows.h>
  4. #include <time.h>
  5.  
  6. using namespace std;
  7.  
  8. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  9.  
  10. int main(int argc, char** argv) {
  11.  
  12. int x,i=0,j=0,t[4][5],k=0,w=0,suma,suma2;
  13.  
  14. srand(time(0));
  15.  
  16. for(i=0; i<4; i++)
  17.         {
  18.         for(j=0; j<5; j++)
  19.                 {
  20.                 x=(std::rand()%201)-100;
  21.                 t[i][j]=x;
  22.                 }
  23.         }
  24.        
  25. for(k=0; k<4; k++)
  26.         {
  27.         for(w=0; w<5; w++)
  28.                 {
  29.                 cout<<t[k][w]<<" ";
  30.                 suma=suma+t[k][w];
  31.                 }
  32.         cout<<endl;
  33.         }
  34. cout<<"Suma kolumny: "<<suma;
  35.  
  36. cout<<endl<<endl<<"Po transpozycji: "<<endl<<endl;
  37.  
  38.  
  39.  
  40. for(w=0; w<5; w++)
  41.         {
  42.         for(k=0; k<4; k++)
  43.                 {
  44.                 cout<<t[w][k]<<" ";
  45.                 suma2=suma2+t[w][k];
  46.                 }
  47.         cout<<endl;
  48.         }
  49. cout<<"Suma kolumny: "<<suma2;
  50.  
  51.         return 0;
  52. }