Write a program scissors_paper_rock
that takes the moves of two players in a 'best of 3' game of Scissors Paper Rock and returns the winner.
The program should scan two lines of input:
Output Format
Print the following strings for the scenarios below.
If Player 1 wins
Player 1 won!
If Player 2 wins
Player 2 won!
If the game is a draw
It's a draw!
If invalid moves are entered for either or both players
Moves invalid!
The output from your program should look exactly like this:
$ dcc scissors_paper_rock.c -o scissors_paper_rock
$ ./scissors_paper_rock
S P R
R R S
Player 1 won!
$ dcc scissors_paper_rock.c -o scissors_paper_rock
$ ./scissors_paper_rock
S R P
R P S
Player 2 won!
$ dcc scissors_paper_rock.c -o scissors_paper_rock
$ ./scissors_paper_rock
A B C
D E F
Moves invalid!
R
, scissors by the character S
, and paper by the character P
.When you think your program is working, you can use CSE autotest to test your solution.
$ 1511 csesoc-autotest scissors_paper_rock
You can view the solution code to this problem here.