UVa 409 - Excuses, Excuses!
2013-04-10 21:41
561 查看
#include <cstdio> #include <cstring> #include <cctype> #include <map> using namespace std; char keywords[22][22]; //keywords char excuses_o[22][72]; //原始excuses char excuses[22][72]; //转化为小写后 int e_k[22]; //每个语句含有keyword数统计 void lower(int e) { int i; char *p; for(i=0; i<e; i++) { p = excuses[i]; while(*p) { *p = tolower(*p); p++; } } } bool in_keywords(int k, char *word) { int i; for(i=0; i<k; i++) { if(strcmp(word, keywords[i]) == 0) return true; } return false; } int main() { #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); #endif int k, e, i, l, max, j=0; char *p; bool found; char word[72]; while(scanf("%d%d\n", &k, &e)==2) { j++; for(i=0; i<k; i++) { scanf("%s\n", keywords[i]); } for(i=0; i<e; i++) { fgets(excuses_o[i], sizeof(excuses_o[0]), stdin); } memcpy(excuses, excuses_o, sizeof(excuses_o)); memset(e_k, 0, sizeof(e_k)); lower(e); max = 0; for(i=0; i<e; i++) { l = 0; found = false; p = excuses[i]; while(*p || found) { if(isalpha(*p)) { found = true; word[l++] = *p; } else if(found){ word[l] = 0; found = false; if(in_keywords(k, word)) { e_k[i]++; if(e_k[i] > max) max = e_k[i]; } l = 0; } p++; } } printf("Excuse Set #%d\n", j); for(i=0; i<e; i++) { if(e_k[i] == max) { printf("%s", excuses_o[i]); } } printf("\n"); } }
相关文章推荐
- UVA 409 - Excuses, Excuses!(字符串)
- uva 409 - Excuses, Excuses!
- UVa 409 Excuses, Excuses!
- UVa 409 - Excuses, Excuses!
- uva 409 Excuses, Excuses!(字符串模拟)
- UVa 409 Excuses, Excuses!
- UVA 409 Excuses(借口)
- UVa 409 Excuses, Excuses!
- UVa 409 - Excuses, Excuses!
- UVA之409 - Excuses, Excuses!
- UVa409_Excuses, Excuses!(小白书字符串专题)
- Uva 409 - Excuses, Excuses!
- UVa 409 Excuses, Excuses!
- 字符串训练------UVA 409题目 Excuses, Excuses!
- uva-409 - Excuses, Excuses!
- uva 409 - Excuses, Excuses!
- UVa 409 Excuses, Excuses! (字符串匹配)
- UVA409 - Excuses, Excuses!
- uva 409 - Excuses, Excuses!
- UVA - 409 Excuses, Excuses!