-
-
Save codecademydev/75d507f9b27c5430352ab148071901c3 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdlib.h> | |
int main() { | |
srand (time(NULL)); | |
int computer = rand() % 3 + 1; | |
int user = 0; | |
std::cout << "====================\n"; | |
std::cout << "rock paper scissors!\n"; | |
std::cout << "====================\n"; | |
std::cout << "1) ✊\n"; | |
std::cout << "2) ✋\n"; | |
std::cout << "3) ✌️\n"; | |
std::cout << "shoot! "; | |
std::cin >> user; | |
if ((user == 1 && computer == 3) || (user == 2 && computer ==1) || (user == 3 && computer == 2)){ | |
std::cout << "You win!\n"; | |
} else if ((user == 1 && computer == 2) || (user == 2 && computer == 3) || (user == 3 && computer == 1)) { | |
std::cout << "Computer win!\n"; | |
} else if (user == computer) { | |
std::cout << "Tied\n"; | |
} else { | |
std::cout << "Error, please use 1-3\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment