1
+ // #include<iostream>
2
+ // using namespace std;
3
+ // struct Game{
4
+ // char player1;
5
+ // char player2;
6
+ // };
7
+ // Game games(){
8
+ // Game a;
9
+ // cout<<"Game (C= Scissor,S=Stone,P=Paper)"<<endl;
10
+ // cout<<"Player 1(C or S or P)"<<endl;
11
+ // cin>>a.player1;
12
+ // cout<<"Player 2(C or S or P)"<<endl;
13
+ // cin>>a.player2;
14
+ // return a;
15
+ // }
16
+ // void winner(Game a){
17
+ // if(a.player1 =='C'&& a.player2 =='P'){
18
+ // cout<<"Player 1 is winner"<<endl;
19
+ // }
20
+ // else if(a.player1 ='P'&& a.player2 =='C'){
21
+ // cout<<"Player 2 is winner"<<endl;
22
+ // }
23
+ // else if(a.player1 =='P'&& a.player2 =='S'){
24
+ // cout<<"Player 1 is winner"<<endl;
25
+ // }
26
+ // else if(a.player1 =='S'&& a.player2 =='P'){
27
+ // cout<<"Player 2 is winner"<<endl;
28
+ // }
29
+ // else if(a.player1 =='C'&& a.player2 =='S'){
30
+ // cout<<"Player 2 is winner"<<endl;
31
+ // }
32
+ // else if(a.player1 =='S'&& a.player2 =='C'){
33
+ // cout<<"Player 1 is winner"<<endl;
34
+ // }
35
+ // else if(a.player1 =='P'&& a.player2 =='P'||a.player1 =='S'&& a.player2 =='S'||a.player1 =='C'&& a.player2 =='C'){
36
+ // cout<<"Player 2 is winner"<<endl;
37
+ // }
38
+ // }
39
+ // int main(){
40
+ // cout<<"Start the GAME:"<<endl;
41
+ // Game g[1];
42
+ // g[0] = games();
43
+ // winner(g[0]);
44
+
45
+ // return 0;
46
+ // }
47
+ // #include<iostream>
48
+ // using namespace std;
49
+
50
+ // // Define struct for Game
51
+ // struct Game {
52
+ // char player1;
53
+ // char player2;
54
+ // };
55
+
56
+ // // Function to play a single game round and return a Game object
57
+ // Game games() {
58
+ // Game a;
59
+ // cout << "Game (C= Scissor, S= Stone, P= Paper)" << endl;
60
+ // cout << "Player 1 (C or S or P): ";
61
+ // cin >> a.player1;
62
+ // cout << "Player 2 (C or S or P): ";
63
+ // cin >> a.player2;
64
+ // return a;
65
+ // }
66
+
67
+ // // Function to determine and print the winner
68
+ // void winner(Game a) {
69
+ // if ((a.player1 == 'C' && a.player2 == 'P') ||
70
+ // (a.player1 == 'P' && a.player2 == 'S') ||
71
+ // (a.player1 == 'S' && a.player2 == 'C')) {
72
+ // cout << "Player 1 is the winner!" << endl;
73
+ // } else if ((a.player1 == 'P' && a.player2 == 'C') ||
74
+ // (a.player1 == 'S' && a.player2 == 'P') ||
75
+ // (a.player1 == 'C' && a.player2 == 'S')) {
76
+ // cout << "Player 2 is the winner!" << endl;
77
+ // } else {
78
+ // cout << "It's a draw!" << endl;
79
+ // }
80
+ // }
81
+
82
+ // int main() {
83
+ // cout << "Start the GAME:" << endl;
84
+
85
+ // // Array to hold multiple games (currently set to hold 1 game)
86
+ // Game g[1];
87
+
88
+ // // Play one round of the game
89
+ // g[0] = games();
90
+
91
+ // // Determine and print the winner
92
+ // winner(g[0]);
93
+
94
+ // return 0;
95
+ // }
96
+
97
+ #include < iostream>
98
+ using namespace std ;
99
+ void win (string ans1, string ans2){
100
+ if (ans1==" rock" and ans2 == " paper" ){
101
+ cout<<" Person with paper sign won" <<endl;
102
+ }
103
+ else if (ans1==" rock" and ans2 == " scissor" ){
104
+ cout<<" Person with rock sign won" <<endl;
105
+ }
106
+ else if (ans1==" paper" and ans2 == " rock" ){
107
+ cout<<" Person with paper sign won" <<endl;
108
+ }
109
+ else if (ans1==" scissor" and ans2 == " rock" ){
110
+ cout<<" Person with rock sign won" <<endl;
111
+ }
112
+ else if (ans1==" paper" and ans2 == " scissor" ){
113
+ cout<<" Person with scissor won" <<endl;
114
+ }
115
+ else if (ans1==" scissor" and ans2 == " paper" ){
116
+ cout<<" Person with rock sign won" <<endl;
117
+ }
118
+ else {
119
+ cout<<" Invalid" <<endl;
120
+ }
121
+ }
122
+ int main (){
123
+ string ans1, ans2;
124
+ cout<<" Enter the possibility1: " <<endl;
125
+ cin>>ans1;
126
+ cout<<" Enter the possibility2: " <<endl;
127
+ cin>>ans2;
128
+ win (ans1,ans2);
129
+ }
0 commit comments