-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrock- paper-scissors game.cpp
More file actions
49 lines (39 loc) · 1.03 KB
/
rock- paper-scissors game.cpp
File metadata and controls
49 lines (39 loc) · 1.03 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
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
int x, probability ;
cout << "rock, paper, scissors game \n"<< " pick one of them : \n";
string pick , computer ;
string list[3]={"rock" ,"paper" ,"scissors" };
cin >> pick;
x= time(0) , probability;
srand(x);
probability= 1 + rand()% 3;
if(probability == 1){
cout << "";
computer = list[0];
}
else if(probability == 1){
cout << "";
computer = list[1] ;
}
else{
cout << "";
computer = list[2] ;
}
cout << computer << endl;
if (computer == pick ){
cout << "draw"<<endl ;
}
else if (computer != pick){
if ((computer=="rock" && pick =="paper")||(computer=="scissors" && pick=="rock")||(computer=="paper" && pick =="scissors")){
cout << "you won ";}
else if((pick == "rock" && computer == "paper") || (pick == "scissors" && computer == "rock") || (pick == "paper" && computer == "scissors")
){
cout << "you lose" << endl;}}
else{
cout<< "";
}
return 0;
}