-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrockpaperscissors.cpp
More file actions
97 lines (86 loc) · 1.8 KB
/
rockpaperscissors.cpp
File metadata and controls
97 lines (86 loc) · 1.8 KB
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
89
90
91
92
93
94
95
96
97
#include <iostream>
using namespace std;
void you_win()
{
cout << "You win!" << endl;
}
void you_lose()
{
cout << "You Lose :(" << endl;
}
void you_tie()
{
cout << "That's a tie!!" << endl;
}
int main()
{
cout << "1. Paper" << endl;
cout << "2. Rock" << endl;
cout << "3. Scissors" << endl;
cout << "What is your choice: ";
int player_choice;
cin >> player_choice;
cout<< endl;
srand(time(NULL));
int comp_choice = rand() % 3 + 1;
if (player_choice == 1)
{
cout << "Your choice is: Paper" << endl;
cout << "Computer choice is: ";
if (comp_choice == 1)
{
cout << "Paper" << endl;
you_tie();
}
else if (comp_choice == 2)
{
cout << "Rock" << endl;
you_win();
}
else
{
cout << "Scissors" << endl;
you_lose();
}
}
if (player_choice == 2)
{
cout << "Your choice is: Rock" << endl;
cout << "Computer choice is: ";
if (comp_choice == 1)
{
cout << "Paper" << endl;
you_lose();
}
else if (comp_choice == 2)
{
cout << "Rock" << endl;
you_tie();
}
else
{
cout << "Scissors" << endl;
you_win();
}
}
if (player_choice == 3)
{
cout << "Your choice is: Scissors" << endl;
cout << "Computer choice is: ";
if (comp_choice == 1)
{
cout << "Paper" << endl;
you_win();
}
else if (comp_choice == 2)
{
cout << "Rock" << endl;
you_lose();
}
else
{
cout << "Scissors" << endl;
you_tie();
}
}
}