Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
请大牛帮忙看一下为什么会WA?~~~~~~~~谢谢!#include<iostream> #include<string> using namespace std; int main() { int n; cin>>n; getchar(); string candi[20]; string party[20]; int i; for(i=0;i<n;i++) { getline(cin,candi[i]); getline(cin,party[i]); } int m; cin>>m; getchar(); int count[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; string elect[10000]; for(i=0;i<m;i++) { getline(cin,elect[i]); for(int j=0;j<n;j++) { if(elect[i]==candi[j]){ count[j]++;break;} } } int t=0; for(int j=1;j<n;j++) if(count[t]<count[j]){t=j;} int max=count[t]; count[t]=0; int p=0; for(j=1;j<n;j++) if(count[p]<count[j]) {p=j;} if(max==count[p]) cout<<"tie"<<endl; else { cout<<party[t]<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator