RafalSobala

zad3/rand

Apr 6th, 2020
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. int a=30,b=40,wynik=0;
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     srand(time(NULL));
  10.     cout << "Suma liczb" << endl;
  11.  
  12.     for(int i=100;i>0;i--){
  13.         wynik = a+rand()%(b-a+1) + wynik;
  14.     }
  15.     cout << wynik;
  16.     return 0;
  17. }
Add Comment
Please, Sign In to add comment