#include<iostream>
using namespace std;
char mp[3] = { 'B','C','J' };
int change(char c) {
if (c == 'B') return 0;
if (c == 'C') return 1;
if (c == 'J') return 2;
}
int main() {
char x1, x2;
int n;
int m1, m2;
cin >> n;
int times_A[3] = { 0 }, times_B[3] = { 0 };
int hand_A[3] = { 0 }, hand_B[3] = { 0 };
for (int i = 0; i < n; i++) {
cin >> x1 >> x2;
m1 = change(x1);
m2 = change(x2);
if ((m1 + 1) % 3 == m2) {
times_A[0]++;
times_B[2]++;
hand_A[m1]++;
}
else if (m1 == m2) {
times_A[1]++;
times_B[1]++;
}
else {
times_B[0]++;
times_A[2]++;
hand_B[m2]++;
}
}
for (int i = 0; i < 3; i++) cout << times_A[i] << " ";
cout << endl;
for (int i = 0; i < 3; i++) cout << times_B[i] << " ";
cout << endl;
int n1, n2;
int temp1 = -1,temp2=-1;
for (int i = 0; i < 3; i++) {
if (hand_A[i] > temp1) {
temp1 = hand_A[i];
n1 = i;
}
}
for (int i = 0; i < 3; i++) {
if (hand_B[i] > temp2) {
temp2 = hand_B[i];
n2 = i;
}
}
cout << mp[n1] << " " << mp[n2];
system("pause");
return 0;
}
【B1018/模拟】锤子剪刀布(巧用数组)
于 2022-02-28 16:20:55 首次发布