Advertisement
PiotrSzewczyk

Zad 3 losowość

Apr 16th, 2020
171
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. using namespace std;
  5.  
  6. int main()
  7.  
  8. {
  9.  
  10.     int suma=0;
  11.     int a=10;
  12.     int b=20;
  13.     srand(time(NULL));
  14.     for(int i=0;i<100;i++){
  15.         cout<<a+rand()%(b-a+1)<<endl;
  16.         suma=suma+(a+rand()%(b-a+1));
  17.     }
  18.     cout<<suma<<endl;
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement