您的位置:首页 > 其它

pat乙 1018. 锤子剪刀布

2016-09-08 15:38 239 查看
#include<iostream>
#include<string>
#include<map>
using namespace std;

map<char,int> m1,m2;

int cmp(char a,char b)
{
if(a=='C')
{
if(b=='J')
{
m1['C']++;
return 1;
}

else if(b=='C')return 0;

else
{
m2['B']++;
return -1;
}

}
else if(a=='J')
{
if(b=='B')
{
m1['J']++;
return 1;
}
else if(b=='J')
{
return 0;
}
else
{
m2['C']++;
return -1;
}
}
else
{
if(b=='C')
{
m1['B']++;
return 1;
}
else if(b=='B')return 0;

else
{
m2['J']++;
return -1;
}
}
}
int  main()
{
int n;
cin>>n;

int ying=0,ping=0;

for(int i=0;i<n;i++)
{
char a,b;
cin>>a>>b;
//		s1.push_back(a);
//		s2.push_back(b);

int tmp=cmp(a,b);

if(tmp>0)ying++;
else if(tmp==0)ping++;

}

cout<<ying<<" "<<ping<<" "<<n-ying-ping<<endl;
cout<<n-ying-ping<<" "<<ping<<" "<<ying<<endl;

int mmax=max(m1['J'],max(m1['C'],m1['B']));

if(m1['B']==mmax)cout<<'B'<<" ";
else if(m1['C']==mmax)cout<<'C'<<" ";
else cout<<"J"<<" ";

mmax=max(m2['J'],max(m2['C'],m2['B']));

if(m2['B']==mmax)cout<<'B';
else if(m2['C']==mmax)cout<<'C';
else cout<<"J";

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: