Guest User

Untitled

a guest
Feb 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. using namespace std;
  6.  
  7. int test()
  8. {
  9. int r = 0;
  10. int i = 0;
  11. while (true) {
  12. r += 18;
  13. i += 1;
  14. if (i >= 5) break;
  15. }
  16. if (rand() / (float) RAND_MAX <= 0.3f)
  17. r += test();
  18. return r;
  19. }
  20. int main()
  21. {
  22. srand(time(NULL));
  23. int sum = 0;
  24. int ST_POSKUSOV = 1000000;
  25. for (int i=0; i<ST_POSKUSOV; i++)
  26. sum += test();
  27. cout << (sum / (float) ST_POSKUSOV);
  28. return 0;
  29. }
Add Comment
Please, Sign In to add comment