Advertisement
nuggetin

rps

Oct 8th, 2021 (edited)
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     std::string rps[3] = {"Rock", "Paper", "Scissors"};
  6.     int pick, randnum = rand()%2;
  7.     std::cout << "Welcome to ROCK PAPER SCISSORS!\nInput your pick (1) Rock, (2) Paper, (3) Scissors" << std::endl;
  8.     std::cin >> pick;
  9.     pick = pick-1;
  10.  
  11.     std::cout << "  " << std::endl;
  12.     std::cout << "Player's pick: " + rps[pick] << std::endl;
  13.     std::cout << "  " << std::endl;
  14.     std::cout << "Computer's pick: " + rps[randnum] << std::endl;
  15.     std::cout << "  " << std::endl;
  16.  
  17.     if (pick == 0 && randnum == 2) {
  18.         std::cout << "You win!";
  19.     }
  20.     else if (pick == 1 && randnum == 0) {
  21.         std::cout << "You win!";
  22.     }
  23.     else if (pick == 2 && randnum == 1) {
  24.         std::cout << "You win!";
  25.     }
  26.     else if (pick == randnum) {
  27.         std::cout << "Draw!";
  28.     }
  29.     else {
  30.         std::cout << "You lose!";
  31.     }
  32. }
  33.  
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement