Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- using namespace std;
- const double N = 1000000;
- bool Res() {
- bool res = false;
- int a[37];
- for (int i = 0; i < 37; i++) {
- a[i] = rand() % 365;
- //cout << a[i] << " ";
- }
- //cout << endl;
- for (int i = 0; i < 36; i++)
- for (int j = i + 1; j < 37; j++) if (a[i] == a[j]) res = true;
- return res;
- }
- int main()
- {
- srand(time(NULL));
- int a(0), b(0);
- for (int i = 0; i < N; i++) {
- if (Res())a++;
- else b++;
- }
- cout << a / N << endl << b / N;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement