-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1018.cpp
105 lines (102 loc) · 1.57 KB
/
1018.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
99
100
101
102
103
104
105
#include<iostream>
using namespace std;
class Man {
private:
int win;
int lose;
int draw;
int C, J, B;
public:
Man(){
win = 0;
lose = 0;
draw = 0;
C = 0;
J = 0;
B = 0;
}
void battle( char me, char he);
void display();
void Win( char t);
char Max();
};
int main() {
Man Jia, Yi;
char tempj, tempy;
int n;
cin >> n;
while(n--) {
cin >> tempj >> tempy;
Jia.battle( tempj, tempy);
Yi .battle( tempy, tempj);
}
Jia.display();
Yi .display();
cout << Jia.Max() << " " << Yi.Max();
return 0;
}
void Man:: battle( char me, char he) {
int cwin = 'c' - 'j',
jwin = 'j' - 'b',
bwin = 'b' - 'c',
res = me - he ;
if( !res) ++draw;
else if( res == jwin || res == -jwin) {
if( res > 0) this->Win(me);
else ++lose;
}
else if(res < 0) this->Win(me);
else ++lose;
}
void Man:: display() {
cout << win << " " << draw << " " << lose << endl;
}
char Man:: Max() {
// cout <<"C:"<< C << ", B:" << B << ", J:" << J << endl;
char t = 'B';
if( B < J) {
t = 'J';
if( J <= C)
t = 'C';
}
else if( B < C) {
t = 'C';
if( C < J)
t = 'J';
}
switch (t) {
case 'C': {
return 'C';
break;
}
case 'J': {
return 'J';
break;
}
case 'B': {
return 'B';
break;
}
}
}
void Man::Win( char t) {
++win;
// cout << "--";
switch (t) {
case 'C': {
++C;
// cout << "--C" << C << endl;
break;
}
case 'J': {
++J;
// cout << "--J" << J << endl;
break;
}
case 'B': {
++B;
// cout << "--B" << B << endl;
break;
}
}
}