KarolWozniak

Losowanie Zadanie 3

Mar 31st, 2020
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4.  
  5. using namespace std;
  6. int a=10,b=20,c,d;
  7.  
  8. int main()
  9. {
  10.     srand(time(NULL));
  11.     for(int i=1;i<=100;i++)
  12.     {
  13.         c=a+rand()%(b-a+1);
  14.         d=d+c;
  15.     }
  16.     cout << "Suma 100 losowych liczb z przedzialu <10;20> wynosi: " << d;
  17.     return 0;
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment