티스토리 뷰
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #include<cstdlib> #include<iostream> #include<algorithm> #include<vector> #include<ctime> using namespace std; int main() { int count = 0; srand((unsigned int)time(nullptr)); for(int n = 0; n < 10000; n ++) { vector<int> choices = {0, 0, 1}; random_shuffle(choices.begin(), choices.end()); int choice = rand() % 3; for(int i = 0; i < 3; i ++) { if(i == choice) { continue; } if(choices[i] == 0) { choices.erase(choices.begin() + i); break; } } choice = 1 - min(choice, 1); count += choices[choice]; } cout << count << endl; system("pause"); return 0; } | cs |
친구랑 몬티홀 딜레마 문제에 대해서 어느게 확률이 더 높냐로 2시간싸우다가 코드로 증명했습니다.
'프로그래밍 > C++' 카테고리의 다른 글
[C++]new Class;와 new Class();의 차이 (0) | 2017.06.27 |
---|---|
[C++]STL 프로그래밍 std::list (0) | 2017.03.06 |
[C++]STL 프로그래밍 std::vector (0) | 2017.03.06 |
[C++] 연산자 오버로딩(Operator) (0) | 2017.03.05 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- DirectX9
- c#
- ObjectPool
- 3D
- 기경
- 파일저장
- STL
- 노맨즈 스카이
- 오브젝트풀
- 저장
- 2048 코드
- 몬티홀 딜레마
- Save
- 불러오기
- load
- PlayerPrefs
- 직렬화
- DirectX
- 프로그래밍
- Tap-Titans
- 프레임워크
- 표창 키우기
- 게임
- UI
- Unity
- ObjectPooling
- 기능경기
- 시간 능력
- C++
- Serialization
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
글 보관함