12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
#include <iostream> #include <ctime> #include <cstdlib> using namespace std; int getUserChoice() { int choice; do { cout <<"1. Rock\n"; cout <<"2. Paper\n"; cout <<"3. Scissors\n"; cout <<"4. Lizard\n"; cout <<"5. Spock\n"; cout <<"Enter a choice: "; cin >> choice; cin.clear(); cin.ignore(); }while(cin.fail() || (choice < 1) || (choice > 5)); return choice; } int getComputerChoice() { srand(time(0)); int computerChoice; computerChoice = (rand() % 5) + 1; return computerChoice; } int determineWinner(); int displayChoice() { switch(getUserChoice) { case 1 : cout << "You chose Rock"; break; case 2 : cout << "You chose Paper"; break; case 3 : cout << "You chose Scissors"; break; case 4 : cout << "You chose Lizard"; break; case 5 : cout << "You chose Spock"; break; } } int main() { getComputerChoice(); getUserChoice();
switch(getUserChoice())