Advertisement
Michal_Pilarski

zad12 tablice

Apr 17th, 2020
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4.  
  5. using namespace std;
  6. int w,k, suma=0;
  7. int main()
  8. {
  9.     srand(time(NULL));
  10.     int tab[w][k];
  11.     cout << "Podaj ilosc wierszy: ";
  12.     cin >> w;
  13.     cout << "Podaj ilosc kolumn: ";
  14.     cin >> k;
  15.  
  16.     for(int i=1; i<=w; i++)
  17.     {
  18.         for(int j=1; j<=k; j++)
  19.         {
  20.             tab[w][k] = rand()%100+1;
  21.         }
  22.     }
  23.     for(int i=1; i<=w; i++)
  24.     {
  25.         for(int j=1; j<=k; j++)
  26.         {
  27.             suma = suma + tab[w][k];
  28.         }
  29.  
  30.     }
  31.     cout<<"Suma wszystkich elementow: "<<suma<<endl;
  32.     cout<<"Ilosc wszystkich macierzy: "<<w*k<<endl;
  33.     cout<<"Srednia: "<<suma/(w*k)<<endl;
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement