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 |
老是wronganswer, 不明白啊! 谁能帮忙看下(code);#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; void main() { int len, i, j, max, p; char alp[81]; string tmp; vector< string > ans; vector<int> index; while(scanf("%s", alp) != EOF) { len = strlen(alp); tmp = ""; i = len - 1; p = 1; for(i = len-1; i >= 0; i--) if((alp[i]>='a'&& alp[i]<='z')||(alp[i]>='A'&&alp[i]<='Z')||(alp[i]>='0'&&alp[i]<='9')) break; for(j = 0; j <= i; j++) { if(isupper(alp[j])) alp[j] = tolower(alp[j]); tmp += alp[j]; } ans.insert(ans.end(), tmp); index.insert(index.end(), 0); } sort(ans.begin(), ans.end()); max = 0; if(ans.size()) { index[0] = 1; max = 1; } for(i = 1; i < ans.size(); i++) { if(ans[i] == ans[i-1]) index[i] = index[i-1] + 1; else index[i] = 1; if(index[i] > max) max = index[i]; } printf("%d occurrences\n", max); for(i = 0; i < ans.size(); i++) { if(index[i] == max) cout << ans[i] << endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator