A and B play rock paper scissors: 'R' rock, 'P' paper, 'S' scissors. Rock beats scissors, scissors beat paper, paper beats rock. Write rps(a, b) to return "draw" if they are the same, "A wins" if A wins and "B wins" if B wins.
rps('R', 'S')→'A wins'rps('R', 'P')→'B wins'rps('P', 'P')→'draw'const char *rps(char a, char b)const char *rps(char a, char b) {
if (a == b) {
return "draw";
}
// your code here: the three ways A wins: return "A wins"
return "B wins";
}
Run tries the examples. When they look right, Submit.