#include <iostream>
using namespace std;
int main()
{
srand(time(0));
const int SCISSORS = 1;
const int ROCK = 2;
const int PAPER = 3;
int CWin = 0;
int MWin = 0;
while (true) {
cout << "가위-1 바위-2 보-3 중 하나를 고르시오" << endl;
if (MWin + CWin == 0) {
cout << "전적이 없습니다." << endl;
}
else
cout << "승률" << ((float)MWin / (MWin + CWin))*100 <<"% "<<
MWin<<"승 "<<CWin<<"패"<< endl;
cout << ">>";
int Cvalue = rand() % 3 + 1;
int Mvalue;
cin >> Mvalue;
if (Mvalue == SCISSORS) {
switch (Cvalue) {
case SCISSORS:
cout << "플레이어(가위) vs 컴퓨터(가위) 비겼습니다."<<endl;
break;
case ROCK:
cout << "플레이어(가위) vs 컴퓨터(바위) 졌습니다." << endl;
CWin++;
break;
case PAPER:
cout << "플레이어(가위) vs 컴퓨터(보) 이겼습니다." << endl;
MWin++;
break;
}
}
else if (Mvalue == ROCK) {
switch (Cvalue) {
case SCISSORS:
cout << "플레이어(바위) vs 컴퓨터(가위) 이겼습니다." << endl;
MWin++;
break;
case ROCK:
cout << "플레이어(바위) vs 컴퓨터(바위) 비겼습니다." << endl;
break;
case PAPER:
cout << "플레이어(바위) vs 컴퓨터(보) 졌습니다." << endl;
CWin++;
break;
}
}
else if (Mvalue == PAPER) {
switch (Cvalue) {
case SCISSORS:
cout << "플레이어(보) vs 컴퓨터(가위) 졌습니다." << endl;
CWin++;
break;
case ROCK:
cout << "플레이어(보) vs 컴퓨터(바위) 이겼습니다." << endl;
MWin++;
break;
case PAPER:
cout << "플레이어(보) vs 컴퓨터(보) 비겼습니다." << endl;
break;
}
}
else {
cout << "잘못 입력하셨습니다." << endl;
}
cout << endl;
}
}