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; }
相关文章推荐
- PAT(乙) 1018. 锤子剪刀布 (20)
- PAT乙级.1018. 锤子剪刀布 (20)
- 【PAT】(乙级)1018. 锤子剪刀布 (20)
- 乙级 PAT 1018. 锤子剪刀布 (20)
- [PAT乙级]1018. 锤子剪刀布 (20)
- PAT 1018. 锤子剪刀布
- 编程题目: PAT 1018. 锤子剪刀布 (20)
- 1018. 锤子剪刀布 (20)--PAT乙级
- PAT-乙级-1018. 锤子剪刀布 (20)
- pat1018:锤子剪刀布
- 编程题目: PAT 1018. 锤子剪刀布 (20)
- PAT-B 1018. 锤子剪刀布
- pat_b_1018 锤子剪刀布
- PAT乙级1018. 锤子剪刀布 (20)
- PAT 乙级 1018. 锤子剪刀布 (20)
- 【C++】浙大PAT (Basic Level)1018. 锤子剪刀布 (20)
- PAT(Basic Level)_1018_锤子剪刀布
- PAT1018. 锤子剪刀布 (20)
- PAT B 1018. 锤子剪刀布
- 1018. 锤子剪刀布 (20)-PAT乙级