#include<stdio.h>
#include<time.h>
#include<stdlib.h>
#define size 3
int main()
{
int gVar;
int CPU;
int ch;
srand(time(NULL));
printf("Players choice: Rock 0, Paper 1, Scissor 2\n");
do
{
printf("Enter your choice: Rock 0, Paper 1, Scissor 2\n");
scanf("%d", &gVar);
CPU = rand()%size;
if(gVar == CPU)
{
printf("its a tie: Your choice = %d, CPU = %d\n", gVar, CPU);
}
else if(gVar < CPU)
{
if(gVar==0 && CPU == 2 )
{
printf("You Won: Your choice = %d, CPU = %d\n", gVar, CPU);
}
else
{
printf("CPU Won: Your choice =%d, CPU = %d\n", gVar, CPU);
}
}
else
{
if(CPU == 0 && gVar == 2)
{
printf("CPU Won: Your Choince = %d, CPU =%d\n", gVar, CPU);
}
else
{
printf("You Won: Your Choice = %d, CPU =%d\n", gVar, CPU);
}
}
printf("Enter 5 to play again\n");
scanf("%d",&ch);
}while(ch == 5);
return 0;
}