Ad

You need to resolve the famous game of Big Bang Theory.

for resume :

Scissors cut paper and decapited lizard.

Paper disproves Spock and covers rocks.

Lizard poison Spock and eats paper.

Spock smashes scissors and vaporizes rock.

rock crushes scissors and crushes lizard.

and return draw if draw.


I'm a student please be kind to my mistakes :)

string rps(const std::string p1, const std::string p2)
{
 
 std::map<std::string, int> dict;

 dict["rock"] = 0;
 dict["paper"] = 1;
 dict["scissors"] = 2;
 dict["lizard"] = 3;
 dict["spock"] = 4;

 if(p1 == p2) return "Draw!";

 if(dict[p1] == 0){

 if(dict[p2] == 1) return "Player 2 won!";
 if(dict[p2] == 2) return "Player 1 won!";
 if(dict[p2] == 3) return "Player 1 won!";
 if(dict[p2] == 4) return "Player 2 won!";

 }
 if(dict[p1] == 1){
 if(dict[p2] == 0) return "Player 1 won!";
 if(dict[p2] == 2) return "Player 2 won!";
 if(dict[p2] == 3) return "Player 2 won!";
 if(dict[p2] == 4) return "Player 1 won!";
 }
 if(dict[p1] == 2){
 if(dict[p2] == 0) return "Player 2 won!";
 if(dict[p2] == 1) return "Player 1 won!";
 if(dict[p2] == 3) return "Player 1 won!";
 if(dict[p2] == 4) return "Player 2 won!";
 }
 if(dict[p1] == 3){
 if(dict[p2] == 0) return "Player 2 won!";
 if(dict[p2] == 1) return "Player 1 won!";
 if(dict[p2] == 2) return "Player 2 won!";
 if(dict[p2] == 4) return "Player 1 won!";
 }
 if(dict[p1] == 4){
 if(dict[p2] == 0) return "Player 1 won!";
 if(dict[p2] == 1) return "Player 2 won!";
 if(dict[p2] == 2) return "Player 1 won!";
 if(dict[p2] == 3) return "Player 2 won!";
 }
}