原始问题:
写一个游戏代码
// Here's a simple game of rock, paper, scissors.
include
include
include <stdlib.h> // for random number generator
using namespace std;
int main() {
string player1; //player 1 input
string player2; //player 2 input
cout << "Player 1: Rock, Paper or Scissors? ";
cin >> player1;
cout << "Player 2: Rock, Paper or Scissors? ";
cin >> player2;
if (player1 == player2) { //if both players enter the same thing cout << "It's a tie!" << endl; return 0; } else if (player1 == "Rock") { if (player2 == "Paper") { cout << "Player 2 wins!" << endl; return 0;} else if (player2 == "Scissors"){ cout <<"Player 1 wins!"<<endl ; return 0;} } else if (player1 == "Paper") { if(player2=="Rock"){ cout<<"Player 1 wins!"<<endl ; return 0;} else if(player2=="Scissors"){ cout<<"Player 2 wins!"<<endl ; return 0;} } else if(player1=="Scissors"){ if(player2=="Rock"){ cout<<"Player 2 wins!"<<endl ; return 0;} else if(player2=="Paper"){ cout<<"Player 1 wins!"<<endl ; return 0;} } }
Prev:毕业合影小红书文案,暗恋