Name this program rpsls. c - The game of rock-paper-scissors was expanded so tha
ID: 3796208 • Letter: N
Question
Name this program rpsls. c - The game of rock-paper-scissors was expanded so that it now includes rock-paper-scissors-lizard-spock. The expansion was created by Sam Kass and Karen Bryla and made famous on the Big Bang Theory. This program builds on the rock-paper-scissors program you wrote earlier. It still does the same basic processing that you did earlier. Assume that 0 = rock, 1 = paper, 2 = scissors, 3 = lizard, and 4 = spock. The main program is shown below, int main() {srand(0); int a, games, p1, p2, ans, ties = 0, p1wins=0, p2wins=0; games = numGames(); for (a=0; aExplanation / Answer
int numGames()
{
cout<<"Enter number of games to play:";//prompting
int n;
cin>>n;//reading integer
return n;//returning
}
int winner(int p1,int p2)
{
if(p1==p2)return 0;//if tie
if(p1>p2)return 1;//if p1 wins
return 2;//if p2 wins
}
void printResults(int a,int b,int c,int d)
{
cout<<"Total number of games:"<<a<<" ";
cout<<"Number of ties:"<<b<<" ";
cout<<"Player 1 wins:"<<c<<" ";
cout<<"Player 2 wins:"<<d<<" ";
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.