rock paper scisssor - pass
#include <stdio.h>
#include<stdlib.h>
#include<time.h>
#include <string.h>
int main() {
// Write C code here
int b;
printf("Enter your choice between and input your value \nRock - 1\nPaper - 2\nScissor - 3\n");
scanf("%d",&b);
int a ;
srand(time(0));
a = rand()%3+1;
printf("Your choice is : ");
if (b==1){
printf("Rock\n");
}
else if (b==2){
printf("Paper\n");
}
else if (b==3){
printf("Scissor\n");
}
if (a==1){
printf("com choice is : Rock\n");
}
else if (a==2){
printf("com choice is : Paper\n");
}
else if (a==3){
printf("com choice is : Scissor\n");
}
//rock< paper <scissor<rock
//80 70 90 80
// u b c a res
// 1R(80) > 2P(70) C
// 1R(80) < 3S(90) U
// 2P(70) < 1R(80) U
// 2P(70) < 3S(90) C
// 3S(90) > 1R(80) C
// 3S(90) > 2P(70) U
if(a==b){
printf("Game is tie ");
}
else if(b==1 && a==2){
printf("Computer won ");
}
else if(b==1 && a==3){
printf("You won ");
}
else if(b==2 && a==1){
printf("You won ");
}
else if(b==2 && a==3){
printf("Computer won ");
}
else if(b==3 && a==1){
printf("Computer won ");
}
else if(b==3 && a==2){
printf("You won ");
}
return 0;
}
Comments
Post a Comment