Advertisement
efeertas

cointoss

Mar 13th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4.  
  5. using namespace std;
  6.  
  7. int tail = 0;
  8. int head = 0;
  9.  
  10. void cointoss()
  11. {
  12. int coin;
  13. coin = rand() % 2;
  14. if (coin == 0)
  15. {
  16. head++;
  17. cout << "head" << endl;
  18.  
  19. }
  20. else
  21. {
  22. tail++;
  23. cout << "tail" << endl;
  24. }
  25. }
  26.  
  27. int main ()
  28. {
  29. srand (time(0) );
  30. for ( int x = 0; x <10 ; x++ )
  31. {
  32. cointoss();
  33. }
  34.  
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement