您的位置:首页 > 编程语言 > C语言/C++

PAT 1018.锤子剪刀布 C++

2017-11-29 17:28 357 查看
#include <iostream>
#include<stdio.h>
using namespace std;
//用最朴实的方法,没错,我就是这么lo
int main()
{
int B1=0,B2=0,C1=0,C2=0,J1=0,J2=0,n;
cin>>n;
int p=0;
char a,b;
for(int i=0;i<n;i++) {
cin>>a>>b;
if((a=='C')&&(b=='B')) {
B2++;
}else if((a=='C')&&(b=='J')) {
C1++;
}else if((a=='B')&&(b=='C')) {
B1++;
}else if((a=='B')&&(b=='J')) {
J2++;
}else if((a=='J')&&(b=='C')) {
C2++;
}else if((a=='J')&&(b=='B')){
J1++;
}else {
p++;
}
}
int win1=C1+B1+J1;
int win2=C2+B2+J2;
cout<<win1<<" "<<p<<" "<<win2<<endl;
cout<<win2<<" "<<p<<" "<<win1<<endl;
if(B1>C1&&B1>J1) {
cout<<"B ";
if(B2>C2&&B2>J2) {
cout<<"B";
}else if(C2>B2&&C2>J2) {
cout<<"C";
}else if(J2>B2&&J2>C2) {
cout<<"J";
}else if(B2==C2&&B2>J2) {
cout<<"B";
}else if(B2==J2&&B2>C2) {
cout<<"B";
}else if(C2==J2&&C2>B2) {
cout<<"C";
}else if(C2==J2&&C2==B2) {
cout<<"B";
}
}else if(C1>B1&&C1>J1) {
cout<<"C ";
if(B2>C2&&B2>J2) {
cout<<"B";
}else if(C2>B2&&C2>J2) {
cout<<"C";
}else if(J2>B2&&J2>C2) {
cout<<"J";
}else if(B2==C2&&B2>J2) {
cout<<"B";
}else if(B2==J2&&B2>C2) {
cout<<"B";
}else if(C2==J2&&C2>B2) {
cout<<"C";
}else if(C2==J2&&C2==B2) {
cout<<"B";
}
}else if(J1>B1&&J1>C1) {
cout<<"J ";
if(B2>C2&&B2>J2) {
cout<<"B";
}else if(C2>B2&&C2>J2) {
cout<<"C";
}else if(J2>B2&&J2>C2) {
cout<<"J";
}else if(B2==C2&&B2>J2) {
cout<<"B";
}else if(B2==J2&&B2>C2) {
cout<<"B";
}else if(C2==J2&&C2>B2) {
cout<<"C";
}else if(C2==J2&&C2==B2) {
cout<<"B";
}
}else if(B1==C1&&B1>J1) {
cout<<"B ";
if(B2>C2&&B2>J2) {
cout<<"B";
}else if(C2>B2&&C2>J2) {
cout<<"C";
}else if(J2>B2&&J2>C2) {
cout<<"J";
}else if(B2==C2&&B2>J2) {
cout<<"B";
}else if(B2==J2&&B2>C2) {
cout<<"B";
}else if(C2==J2&&C2>B2) {
cout<<"C";
}else if(C2==J2&&C2==B2) {
cout<<"B";
}
}else if(B1==J1&&B1>C1) {
cout<<"B ";
if(B2>C2&&B2>J2) {
cout<<"B";
}else if(C2>B2&&C2>J2) {
cout<<"C";
}else if(J2>B2&&J2>C2) {
cout<<"J";
}else if(B2==C2&&B2>J2) {
cout<<"B";
}else if(B2==J2&&B2>C2) {
cout<<"B";
}else if(C2==J2&&C2>B2) {
cout<<"C";
}else if(C2==J2&&C2==B2) {
cout<<"B";
}
}else if(C1==J1&&C1>B1) {
cout<<"C ";
if(B2>C2&&B2>J2) {
cout<<"B";
}else if(C2>B2&&C2>J2) {
cout<<"C";
}else if(J2>B2&&J2>C2) {
cout<<"J";
}else if(B2==C2&&B2>J2) {
cout<<"B";
}else if(B2==J2&&B2>C2) {
cout<<"B";
}else if(C2==J2&&C2>B2) {
cout<<"C";
}else if(C2==J2&&C2==B2) {
cout<<"B";
}
}else if(C1==J1&&C1==B1) {
cout<<"B ";
if(B2>C2&&B2>J2) {
cout<<"B";
}else if(C2>B2&&C2>J2) {
cout<<"C";
}else if(J2>B2&&J2>C2) {
cout<<"J";
}else if(B2==C2&&B2>J2) {
cout<<"B";
}else if(B2==J2&&B2>C2) {
cout<<"B";
}else if(C2==J2&&C2>B2) {
cout<<"C";
}else if(C2==J2&&C2==B2) {
cout<<"B";
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  C++ PAT PAT1018 PAT乙级