Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <stdio.h>
- #include <time.h>
- #include <string>
- using namespace std;
- int main()
- {
- string choice;
- int computer;
- cout << "Rock, Paper, or Scissors?" << endl;
- cout << " " << endl;
- cin >> choice;
- if (choice == "Rock" || choice == "Paper" || choice == "Scissors")
- {
- cout << "You chose " << choice << endl;
- }
- else if (choice != "Rock" || choice != "Paper" || choice != "Scissors")
- {
- cout << "That's not a valid choice. Please try again." << endl;
- }
- srand(time(NULL));
- computer = rand() % 3 + 1;
- if (computer == 1)
- {
- cout << "Computer chose rock." << endl;
- }
- else if (computer == 2)
- {
- cout << "Computer chose paper." << endl;
- }
- else if (computer == 3)
- {
- cout << "Computer chose Scissors." << endl;
- }
- //Who won
- //Rock
- if (choice == "Rock" && computer == 1)
- {
- cout << "It's a tie!" << endl;
- cin.get();
- }
- else if (choice == "Rock" && computer == 2)
- {
- cout << "You lose kek" << endl;
- cin.get();
- }
- else if (choice == "Rock" && computer == 3)
- {
- cout << "You win" << endl;
- cin.get();
- }
- //paper
- if (choice == "Paper" && computer == 2)
- {
- cout << "It's a tie!" << endl;
- cin.get();
- }
- else if (choice == "Paper" && computer == 3)
- {
- cout << "You lose kek" << endl;
- cin.get();
- }
- else if (choice == "Paper" && computer == 1)
- {
- cout << "You win" << endl;
- cin.get();
- }
- //scissors
- if (choice == "Scissors" && computer == 3)
- {
- cout << "It's a tie!" << endl;
- cin.get();
- }
- else if (choice == "Scissors" && computer == 1)
- {
- cout << "You lose kek" << endl;
- cin.get();
- }
- else if (choice == "Scissors" && computer == 2)
- {
- cout << "You win" << endl;
- cin.get();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement