PTA乙级 (1018 锤子剪刀布 (20分))
1018 锤子剪刀布 (20分)
https://pintia.cn/problem-sets/994805260223102976/problems/994805304020025344
#include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cmath> #include <algorithm> using namespace std; int main() { int n; char chr1=‘C‘,chr2=‘J‘,chr3=‘B‘,c1,c2; int arr1[4]={0},arr2[4]={0}; int win_1=0,equal_1=0; cin>>n; for(int i=0;i<n;i++) { cin>>c1>>c2; if(c1==c2) equal_1++; else if((c1==‘B‘&&c2==‘C‘)||(c1==‘C‘&&c2==‘J‘)||(c1==‘J‘&&c2==‘B‘)) { win_1++; if(c1==‘B‘) arr1[1]++; else if(c1==‘C‘) arr1[2]++; else if(c1==‘J‘) arr1[3]++; } else{ if(c2==‘J‘) arr2[3]++; else if(c2==‘B‘) arr2[1]++; else if(c2==‘C‘) arr2[2]++; } } cout<<win_1<<" "<<equal_1<<" "<<n-win_1-equal_1<<endl; cout<<n-win_1-equal_1<<" "<<equal_1<<" "<<win_1<<endl; int max_1=0,max_2=0; for(int i=1;i<=3;i++) { if(arr1[i]>max_1) max_1=arr1[i]; if(arr2[i]>max_2) max_2=arr2[i]; } for(int i=1;i<=3;i++) { if(arr1[i]==max_1) { if(i==1) cout<<"B"; else if(i==2) cout<<"C"; else if(i==3) cout<<"J"; break; } } for(int i=1;i<=3;i++) { if(arr2[i]==max_2) { if(i==1) cout<<" B"; else if(i==2) cout<<" C"; else if(i==3) cout<<" J"; break; } } return 0; }
相关推荐
锤子科技chuizi 2020-05-01
uyirn 2020-01-23
锤子科技chuizi 2020-01-18
84417613 2020-01-01
uyirn 2019-12-27
89771191 2019-11-04
锤子科技chuizi 2019-11-01
89771191 2015-06-22
gangjiong 2014-12-08
锤子科技接班人 2019-06-30
锤子科技接班人 2013-02-28
86417018 2019-06-27
锤子科技CEO 2010-08-16
老彭0 2019-06-21
aqw 2019-06-25
qiaozhaoxiong 2019-06-21
wxuande 2019-06-20
锤子科技销售经理 2019-06-20