Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
109165 | 胡海峰老师 | 19选班长II | C++ | Accepted | 1 MS | 272 KB | 710 | 2025-02-05 15:21:14 |
#include <iostream> using namespace std; int a[5]={}; int main () { int who; while(1) { cin>>who; if(who==-1) break; if( who==1) a[who]++; else if ( who==2) a[who]++; else if ( who==3) a[who]++; else a[4]++; } int tot = a[1]+a[2]+a[3]+a[4]; cout<<"A="<<a[1]<<endl; cout<<"B="<<a[2]<<endl; cout<<"C="<<a[3]<<endl; cout<<"Tot="<<tot<<endl; //all-NO A-yes if( a[1]>tot/2) cout<<"A-yes"<<endl; else if ( a[2]>tot/2) cout<<"B-yes"<<endl; else if ( a[3]>tot/2) cout<<"C-yes"<<endl; else cout<<"all-NO"<<endl; return 0; } /* Input 1 1 2 2 3 3 3 4 4 -1 Output A=2 B=2 C=3 Tot=9 all-NO */