-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrock_paper_scissors.c
61 lines (57 loc) · 1.17 KB
/
rock_paper_scissors.c
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
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
srand(time(0));
int player, computer = rand() % 3;
/*
0 --> Snake
1 --> Water
2 --> Gun
*/
printf("0 = Snake\n1 = water \n2 = Gun \n");
printf("choose : ");
scanf("%d", &player);
printf("Computer chose %d\n", computer);
if (player == 0 && computer == 0)
{
printf("Its a Draw!\n");
}
else if (player == 0 && computer == 1)
{
printf("You Win!\n");
}
else if (player == 0 && computer == 2)
{
printf("You Lose!\n");
}
else if (player == 1 && computer == 0)
{
printf("You Lose!\n");
}
else if (player == 1 && computer == 1)
{
printf("Its a Draw!\n");
}
else if (player == 1 && computer == 2)
{
printf("You win!\n");
}
else if (player == 2 && computer == 0)
{
printf("You win!\n");
}
else if (player == 2 && computer == 1)
{
printf("You Lose!\n");
}
else if (player == 2 && computer == 2)
{
printf("Its a Draw!\n");
}
else{
printf("Something went wrong!");
}
return 0;
}