Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- std::string rps[3] = {"Rock", "Paper", "Scissors"};
- int pick, randnum = rand()%2;
- std::cout << "Welcome to ROCK PAPER SCISSORS!\nInput your pick (1) Rock, (2) Paper, (3) Scissors" << std::endl;
- std::cin >> pick;
- pick = pick-1;
- std::cout << " " << std::endl;
- std::cout << "Player's pick: " + rps[pick] << std::endl;
- std::cout << " " << std::endl;
- std::cout << "Computer's pick: " + rps[randnum] << std::endl;
- std::cout << " " << std::endl;
- if (pick == 0 && randnum == 2) {
- std::cout << "You win!";
- }
- else if (pick == 1 && randnum == 0) {
- std::cout << "You win!";
- }
- else if (pick == 2 && randnum == 1) {
- std::cout << "You win!";
- }
- else if (pick == randnum) {
- std::cout << "Draw!";
- }
- else {
- std::cout << "You lose!";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement