#include <iostream>
#include <cmath>
#include <string>
#include <ctime>
using namespace std;
int AmIWin(string strRPCInput, string strRPCCom);
int main()
{
srand(time(0));
string userinput="none";
int nuserinput=0;
int ncominput=0;
string comoutput="none";
cout << "가위, 바위, 보 중 하나를 내주세요\n";
cin >> userinput;
ncominput = rand() % 3;
switch (ncominput)
{
case 0:
comoutput = "가위";
cout << "컴퓨터는 가위를 내었습니다.\n";
break;
case 1:
comoutput = "바위";
cout << "컴퓨터는 바위를 내었습니다.\n";
break;
case 2:
comoutput = "보";
cout << "컴퓨터는 보를 내었습니다.\n";
break;
default:
{
cout << "잘못 입력하셨습니다.\n";
}
};
int result = AmIWin(userinput, comoutput);
if (result == 1)
{
cout << "당신은 이기셨습니다.";
}
else if (result == 0)
{
cout << "당신은 비기셨습니다.";
}
else if (result == -1)
{
cout << "당신은 비기셨습니다.";
}
else
{
cout << "오류입니다.";
};
}
int AmIWin(string strRPCInput, string strRPCCom) // 가위바위보 함수
{
int nWin = -8;
if (strRPCInput == "가위")
{
cout << "당신은 가위를 내셨습니다.\n";
if (strRPCCom == "가위")
{
nWin = 0;
}
else if (strRPCCom == "바위")
{
nWin = -1;
}
else if (strRPCCom == "보")
{
nWin = 1;
}
else
{
nWin = -8;
};
}
else if (strRPCInput == "바위")
{
cout << "당신은 바위를 내셨습니다.\n";
if (strRPCCom == "가위")
{
nWin = 1;
}
else if (strRPCCom == "바위")
{
nWin = 0;
}
else if (strRPCCom == "보")
{
nWin = -1;
}
else
{
nWin = -8;
};
}
else if (strRPCInput == "보")
{
cout << "당신은 보를 내셨습니다.\n";
if (strRPCCom == "가위")
{
nWin = -1;
}
else if (strRPCCom == "바위")
{
nWin = 1;
}
else if (strRPCCom == "보")
{
nWin = 0;
}
else
{
nWin = -8;
};
}
else
{
nWin = -8;
};
};
이런 공부해서 실력 절대안늘음 시간낭비
학교 과제라 그래요
디버깅이 안되네요 ;;
return nwin - dc App