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 44 45 46 47 48 49 50 51
| #include <iostream> #include <string> #include <random>
using namespace std;
int main() { int Coin;
random_device rd; mt19937 gen(rd());
uniform_int_distribution<int> dis(0, 1); string com_out;
while (1) { int com = dis(gen);
cout << "동전던지기 시작(1) 종료(0)" << endl; cin >> Coin;
if (Coin == 0) { cout << "종료" << endl; break; }
else if (Coin == 1) { if (com == 0) { cout << "뒷면" << endl; } else if (com == 1) { cout << "앞면" << endl; } } else { cout << "0과 1의 숫자로 다시 시도하세요." << endl; } }
return 0; }
|