MarcinKrol

Zad 4 - Pseudolosowość

Apr 16th, 2020
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. #include <cstdlib>
  4.  
  5. using namespace std;
  6.  
  7. //Zad 4; Pseudolosowosc
  8.  
  9. int a=1;
  10. int b;
  11.  
  12. int main()
  13. {
  14.  
  15.  
  16. cout << "Orzel(0) czy reszka(1)?" << endl;
  17.  
  18.  
  19. cin >> b; cout << endl;
  20.  
  21. srand(time(NULL));
  22.  
  23. if(b==1 || b==0)
  24. {
  25. cout <<rand()%(a+1) ;
  26. }
  27. else
  28. {
  29. cout << "Podales zla wartosc! Podaj liczby z przedzialu (0-1)" << endl;
  30. }
  31.  
  32.  
  33. //Liczby nie powtarzaja sie w nieskonczonosc co nadaje efekt losowosci.
  34.  
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment