错误问题:最后输出甲乙最多赢的最后一行没敲出来,没有想到是对a,b两个人出的分别创建两个数组
#include <iostream>
#include <cstring>
#include<map>
#include<cmath>
using namespace std;
//map<string,int>mp;
int main(){
string ss[4]={"B","C","J"};
int n,aa=0,bb=0,p=0;
int as[3] = {0}, bs[3] = {0};//手势 B C J
char a,b;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a>>b;
if(a=='B')
{
if(b=='C'){
aa++;
as[0]++;
}else if(b=='J'){
bb++;
bs[2]++;
}
else
p++;
}else if(a=='C') {
if(b=='J'){
aa++;
as[1]++;
}else if(b=='B'){
bb++;
bs[0]++;
}
else
p++;
}else if(a=='J') {
if(b=='B'){
aa++;
as[2]++;
}else if(b=='C')
{
bb++;
bs[1]++;
}
else
p++;
}
}
cout<<aa<<" "<<p<<" "<<bb<<endl;
cout<<bb<<" "<<p<<" "<<aa<<endl;
int ax=0,ka=0,kb=0,bx=0;
for(int i=0;i<3;i++){
if(as[i]>ax){
ax=as[i];
ka=i;
}
}
cout<<ss[ka]<<" ";
for(int i=0;i<3;i++){
if(bs[i]>bx){
bx=bs[i];
kb=i;
}
}
cout<<ss[kb];
}在这里插入代码片