forked from sonnynomnom/Codecademy-Learn-C-Plus-Plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rock_paper_scissors.cpp
98 lines (58 loc) · 1.36 KB
/
rock_paper_scissors.cpp
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
98
#include <iostream>
#include <stdlib.h>
int main() {
srand(time(NULL));
int computer = rand() % 3 + 1;
int user;
std::cout << "====================\n";
std::cout << "rock paper scissors!\n";
std::cout << "====================\n";
std::cout << "1) ✊\n";
std::cout << "2) ✋\n";
std::cout << "3) ✌️\n";
std::cout << "shoot! ";
std::cin >> user;
if (user == 1)
std::cout << "you choose: ✊\n";
else if (user == 2)
std::cout << "you choose: ✋\n";
else
std::cout << "you choose: ✌️\n";
if (computer == 1)
std::cout << "cpu choose: ✊\n";
else if (computer == 2)
std::cout << "cpu choose: ✋\n";
else
std::cout << "cpu choose: ✌️\n";
if (user == computer) {
std::cout << "it's a tie!\n";
}
// user rock
else if (user == 1) {
if (computer == 2) {
std::cout << "you lost! booooo!\n";
}
if (computer == 3) {
std::cout << "you won! woohoo!\n";
}
}
// user paper
else if (user == 2) {
if (computer == 1) {
std::cout << "you won! woohoo!\n";
}
if (computer == 3) {
std::cout << "you lost! boo!\n";
}
}
// user scissors
else if (user == 3) {
if (computer == 1) {
std::cout << "you won! woohoo!\n";
}
if (computer == 2) {
std::cout << "you lost! booooo!\n";
}
}
return 0;
}