抄的柳婼小姐姐的,感觉三个数求最大那里用的真棒
#include <stdio.h>
int main() {
int N; scanf("%d", &N);
int jiawin = 0, yiwin = 0, ping = 0;
int jia[3] = { 0 }, yi[3] = { 0 };
for (int i = 0; i<N; i++) {
getchar();
char arr[5]; scanf("%[^
]", arr);
if (arr[0] == arr[2]) ping++;
else if (arr[0] == 'C'&&arr[2] == 'B') {
yiwin++;
yi[0]++;
}
else if (arr[0] == 'C'&&arr[2] == 'J') {
jiawin++;
jia[1]++;
}
else if (arr[0] == 'B'&&arr[2] == 'C') {
jiawin++;
jia[0]++;
}
else if (arr[0] == 'B'&&arr[2] == 'J') {
yiwin++;
yi[2]++;
}
else if (arr[0] == 'J'&&arr[2] == 'C') {
yiwin++;
yi[1]++;
}
else if (arr[0] == 'J'&&arr[2] == 'B') {
jiawin++;
jia[2]++;
}
}
printf("%d %d %d
%d %d %d
", jiawin, ping, yiwin, yiwin, ping, jiawin);
int maxjia = jia[0] >= jia[1] ? 0 : 1;
maxjia = jia[maxjia] >= jia[2] ? maxjia : 2;
int maxyi = yi[0] >= yi[1] ? 0 : 1;
maxyi = yi[maxyi] >= yi[2] ? maxyi : 2;
char str[4] = "BCJ";
printf("%c %c", str[maxjia], str[maxyi]);
return 0;
}