1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
int number,usernumber = 0;
char userpick;
do{
int userscore,compscore;
userscore=0;
compscore=0;
srand(time(0));
number = 1 + (rand() % 3) ;
cout<<"Choose: [Rock, Paper, Scissors or Quit]: ";
cin>>userpick;
if(userpick=='r'|| userpick=='R')
{
usernumber=1;
}
if(userpick=='p'|| userpick=='P')
{
usernumber=2;
}
if(userpick=='s'|| userpick=='S')
{
usernumber=3;
}
if(userpick=='q'|| userpick=='Q')
{
usernumber=4;
}
if(usernumber==number)
{
cout<<"Computers: " <<userpick<< ", Human: "<<userpick<< ", Tie" << endl;
userscore++;
compscore++;
}
if(usernumber==1 && number==2)
{
cout<<"Computer: Paper, Human: Rock, You Lose"<<endl;
compscore++;
}
if(usernumber==1 && number==3)
{
cout<<"Computer: Scissors, Human: Rock, You Win"<<endl;
userscore++;
}
if(usernumber==2 && number==1)
{
cout<<"Computer: Rock, Human Paper, You Win"<<endl;
userscore++;
}
if(usernumber==2 && number==3)
{
cout<<"Computer: Scissors, Human: Paper, You Lose"<<endl;
compscore++;
}
if(usernumber==3 && number==1)
{
cout<<"Computer: Rock, Human: Scissors, You Lose"<<endl;
compscore++;
}
if(usernumber==3 && number==2)
{
cout<<"Computer: Paper, Human Scissors, You Win"<<endl;
userscore++;
}
if(usernumber==4)
{
cout<<"Your Score: "<<userscore<<endl;
cout<<"Computers Score: "<<compscore<<endl;
}
}while(userpick!=4);
return 0;
}
|