PAT 1018.錘子剪刀布 C++
阿新 • • 發佈:2018-11-25
#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"; } } }