简单字符串。
#include <cstdio>
#include <cstring> #define MAXLEN 105
#define MAXN 25 char keys[MAXN][MAXN];
char lines[MAXN][MAXLEN];
int nums[MAXN]; int main() {
int case_n = ;
int n, m, max;
int i, j, k, v;
char tmp[MAXLEN]; while (scanf("%d %d",&n,&m) != EOF) {
for (i=; i<n; ++i)
scanf("%s", keys[i]);
getchar();
memset(nums, , sizeof(nums));
max = -;
for (i=; i<m; ++i) {
gets(lines[i]);
v = ;
for (j=; j<strlen(lines[i]); ++j) {
if (lines[i][j]>='A' && lines[i][j]<='Z') {
tmp[v++] = lines[i][j]-'A'+'a';
} else if (lines[i][j]>='a' && lines[i][j]<='z') {
tmp[v++] = lines[i][j];
} else {
if (v) {
tmp[v++] = '\0';
for (k=; k<n; ++k) {
if (strcmp(tmp, keys[k]) == )
++nums[i];
}
}
v = ;
}
}
if (v) {
tmp[v++] = '\0';
for (k=; k<n; ++k) {
if (strcmp(tmp, keys[k]) == )
++nums[i];
}
}
if (nums[i] > max) max = nums[i];
}
printf("Excuse Set #%d\n", ++case_n);
for (i=; i<n; ++i) {
if (nums[i] == max)
printf("%s\n", lines[i]);
}
printf("\n");
} return ;
}