zoukankan      html  css  js  c++  java
  • 【HDOJ】1606 Excuses, Excuses!

    简单字符串。

     1 #include <cstdio>
     2 #include <cstring>
     3 
     4 #define MAXLEN 105
     5 #define MAXN   25
     6 
     7 char keys[MAXN][MAXN];
     8 char lines[MAXN][MAXLEN];
     9 int nums[MAXN];
    10 
    11 int main() {
    12     int case_n = 0;
    13     int n, m, max;
    14     int i, j, k, v;
    15     char tmp[MAXLEN];
    16 
    17     while (scanf("%d %d",&n,&m) != EOF) {
    18         for (i=0; i<n; ++i)
    19             scanf("%s", keys[i]);
    20         getchar();
    21         memset(nums, 0, sizeof(nums));
    22         max = -1;
    23         for (i=0; i<m; ++i) {
    24             gets(lines[i]);
    25             v = 0;
    26             for (j=0; j<strlen(lines[i]); ++j) {
    27                 if (lines[i][j]>='A' && lines[i][j]<='Z') {
    28                     tmp[v++] = lines[i][j]-'A'+'a';
    29                 } else if (lines[i][j]>='a' && lines[i][j]<='z') {
    30                     tmp[v++] = lines[i][j];
    31                 } else {
    32                     if (v) {
    33                         tmp[v++] = '';
    34                         for (k=0; k<n; ++k) {
    35                             if (strcmp(tmp, keys[k]) == 0)
    36                                 ++nums[i];
    37                         }
    38                     }
    39                     v = 0;
    40                 }
    41             }
    42             if (v) {
    43                 tmp[v++] = '';
    44                 for (k=0; k<n; ++k) {
    45                     if (strcmp(tmp, keys[k]) == 0)
    46                         ++nums[i];
    47                 }
    48             }
    49             if (nums[i] > max) max = nums[i];
    50         }
    51         printf("Excuse Set #%d
    ", ++case_n);
    52         for (i=0; i<n; ++i) {
    53             if (nums[i] == max)
    54                 printf("%s
    ", lines[i]);
    55         }
    56         printf("
    ");
    57     }
    58 
    59     return 0;
    60 }
  • 相关阅读:
    PHP-FPM 重启
    white-space: nowrap
    php-fpm 优化
    & 引用传值
    tp3 save操作小bug误区
    用百度接口验证是否上传了身份证图片信息[非姓名,身份证号匹配]
    nginx 反向代理案例
    IOS把图片缓存到本地的几种方法
    ios沙盒查找图片展示
    iOS模拟器沙盒使用推荐
  • 原文地址:https://www.cnblogs.com/bombe1013/p/3777286.html
Copyright © 2011-2022 走看看