-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathrockPaperScissor.cpp
97 lines (83 loc) Β· 1.75 KB
/
rockPaperScissor.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
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
void game(){
int user;
srand(time(NULL));
int comp_num;
string choice;
cout<<"Select One:"<<endl;
cout<<"1 For Rock"<<endl;
cout<<"2 For Paper"<<endl;
cout<<"3 For Scissor"<<endl;
cin>>user;
//User Choosen
if (user==1){
cout<<"You Choosen Rock"<<endl;
}
else if(user==2){
cout<<"You Choosen Paper"<<endl;
}
else if(user==3){
cout<<"You Choosen Scissor"<<endl;
}
else{
cout<<"Wrong Choosen"<<endl;
}
comp_num=rand()%3+1;
//System Choosen Rock
if (comp_num==1){
cout<<"Computer Choosen Rock"<<endl;
if(user==1){
cout<<"Match Tie"<<endl;
}
else if(user==2){
cout<<"You Win"<<endl;
}
else if(user==3){
cout<<"You Loose"<<endl;
}
}
//System Choosen Paper
else if (comp_num==2){
cout<<"Computer Choosen Paper"<<endl;
if(user==1){
cout<<"You Loose"<<endl;
}
else if(user==2){
cout<<"Match Tie"<<endl;
}
else if(user==3){
cout<<"You Win"<<endl;
}
}
//System Choosen Scissor
else if (comp_num==1){
cout<<"Computer Choosen Scissor"<<endl;
if(user==1){
cout<<"You Win"<<endl;
}
else if(user==2){
cout<<"You Loose"<<endl;
}
else if(user==3){
cout<<"Match Tie"<<endl;
}
}
cout<<""<<endl;
cout<<"Press C To Continue Q to Quit:"<<endl;
cin>>choice;
if(choice=="C"||choice=="c"){
game();
}
else if(choice=="Q"||choice=="q"){
exit(1
);
}
}
main(){
cout<<"WELCOME TO GAME !"<<endl;
cout<<"//if game don't shows the result simply press 'C'"<<endl;
game();
}