添加链接描述
#include <iostream>
#include <vector>
using namespace std;
int max(int a,int b,int c);
int main()
{
int N;char x,y;cin>>N;int x_win=0,y_win=0,peace=0;int jia[3] = {
0},yi[3]={
0};for(int i=0;i<N;i++){
cin>>x>>y;if(x == 'C'&&y == 'J' ){
x_win++;jia[0]++;}else if(x =='B'&&y=='C'){
x_win++;jia[1]++;}else if(x=='J'&&y=='B'){
x_win++;jia[2]++;}else if(x == y){
peace++;}else if(x == 'J'&&y == 'C'){
y_win++;yi[0]++;}else if(x =='C'&&y=='B'){
y_win++;yi[1]++;}else if(x=='B'&&y=='J'){
y_win++;yi[2]++;}}cout<<x_win<<" "<<peace<<" "<<y_win<<"\n";cout<<y_win<<" "<<peace<<" "<<x_win<<"\n";string str = "CBJ";cout<<str[max(jia[0],jia[1],jia[2])]<<" "<<str[max(yi[0],yi[1],yi[2])];return 0;
}
int max(int a,int b,int c)//输入三个数,返回值为最大的哪个数的对应数组下标
{
int m,i;if(a>=c){
m =a;i=0;}else{
m = c;i =2;}if(b>=m){
m = b;i = 1;}return i;}