Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <time.h>
- using namespace std;
- int test()
- {
- int r = 0;
- int i = 0;
- while (true) {
- r += 18;
- i += 1;
- if (i >= 5) break;
- }
- if (rand() / (float) RAND_MAX <= 0.3f)
- r += test();
- return r;
- }
- int main()
- {
- srand(time(NULL));
- int sum = 0;
- int ST_POSKUSOV = 1000000;
- for (int i=0; i<ST_POSKUSOV; i++)
- sum += test();
- cout << (sum / (float) ST_POSKUSOV);
- return 0;
- }
Add Comment
Please, Sign In to add comment