KarolWozniak

Zadanie 12 tablice

Apr 16th, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int w,k,a=1,b=100;
  10. float sr,s,p=0;
  11.     cout << "Podaj ilosc wierszy: ";
  12.     cin >> w;
  13.     cout << "Podajk ilosc kolumn: ";
  14.     cin >> k;
  15. int tab[w][k];
  16.  
  17.      for(int i=0;i<w;i++)
  18.     {
  19.         for(int j=0;j<k;j++)
  20.         {
  21.             tab[i][j]=a+rand()%(b-a+1);
  22.             s=s+tab[i][j];
  23.             p=p+1;
  24.         }
  25.  
  26.     }
  27.     sr=s/p;
  28.  
  29.     cout << "Lacznych elementow: " << p << "\nSuma: " << s << "\nSrednia: " << sr;
  30.  
  31.  
  32.     return 0;
  33. }
Add Comment
Please, Sign In to add comment