Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. using namespace std;
  4. const double N = 1000000;
  5.  
  6. bool Res() {
  7. bool res = false;
  8. int a[37];
  9. for (int i = 0; i < 37; i++) {
  10. a[i] = rand() % 365;
  11. //cout << a[i] << " ";
  12. }
  13. //cout << endl;
  14. for (int i = 0; i < 36; i++)
  15. for (int j = i + 1; j < 37; j++) if (a[i] == a[j]) res = true;
  16. return res;
  17. }
  18.  
  19. int main()
  20. {
  21. srand(time(NULL));
  22. int a(0), b(0);
  23. for (int i = 0; i < N; i++) {
  24. if (Res())a++;
  25. else b++;
  26. }
  27. cout << a / N << endl << b / N;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement