#include #include #include #include int main(void){ int userchoice; int computerchoice; int test; cout << "Enter your choice(0 for paper, 1 for scisser and 2 for rock) :" ; cin >> userchoice ; cout << endl; if (userchoice == 0) cout << "Player picks paper\n"; else if (userchoice == 1) cout << "Player picks scissors\n"; else if (userchoice == 2) cout << "Player picks rocks\n"; srand(time(0)); computerchoice = rand( )%3; if (computerchoice == 0) cout << "Computer picks paper\n"; else if (computerchoice == 1) cout << "Computer picks scissors\n"; else if (computerchoice == 2) cout << "Computer picks rock\n"; if (userchoice == computerchoice) cout << "Draw"; else if (userchoice == 0 && computerchoice == 2) cout << "You win"; else if (computerchoice == 0 && userchoice == 2) cout << "You lose"; else if (userchoice > computerchoice) cout << "You win!!"; else if (computerchoice > userchoice) cout << "You lose"; cin >> test; return 0; } 1
Hosted by www.Geocities.ws