zoukankan      html  css  js  c++  java
  • luogu P1042 乒乓球 模拟

     1 #include <cstdio>
     2 #include <cstring>
     3 #include <algorithm>
     4 using namespace std;
     5 int tot1,tot2,score1_W,score1_L,score2_W,score2_L;
     6 int res1[6000][3],res2[6000][3];
     7 bool fnsh;
     8 int main()
     9 {
    10     int len;
    11     char s[30];
    12     while (scanf("%s",s) > 0)
    13     {
    14         len = strlen(s);
    15         for (int i = 0; i < len; i++)
    16         {
    17             if (s[i] == 'W')
    18             {
    19                 score1_W++;
    20                 score2_W++;
    21             }
    22             else if (s[i] == 'L')
    23             {
    24                 score1_L++;
    25                 score2_L++;
    26             }else if (s[i] == 'E')
    27             {
    28                 fnsh = true;
    29                 break;
    30             }
    31             if (max(score1_W,score1_L) >= 11 && max(score1_W,score1_L) - min(score1_W,score1_L) >= 2)
    32             {
    33                 tot1++;
    34                 res1[tot1][1] = score1_W;
    35                 res1[tot1][2] = score1_L;
    36                 score1_W = 0;
    37                 score1_L = 0;
    38             }
    39             if (max(score2_W,score2_L) >= 21 && max(score2_W,score2_L) - min(score2_W,score2_L) >= 2)
    40             {
    41                 tot2++;
    42                 res2[tot2][1] = score2_W;
    43                 res2[tot2][2] = score2_L;
    44                 score2_W = 0;
    45                 score2_L = 0;
    46             }
    47         }
    48         if (fnsh == true)
    49             break; 
    50     }
    51     tot1++;
    52     res1[tot1][1] = score1_W;
    53     res1[tot1][2] = score1_L;
    54     tot2++;
    55     res2[tot2][1] = score2_W;
    56     res2[tot2][2] = score2_L;
    57     for (int i = 1; i <= tot1; i++)
    58         printf("%d:%d
    ",res1[i][1],res1[i][2]);
    59     printf("
    ");
    60     for (int i = 1; i <= tot2; i++)
    61         printf("%d:%d
    ",res2[i][1],res2[i][2]);
    62     return 0;
    63 }
    心之所动 且就随缘去吧
  • 相关阅读:
    springmvc的文件上传和JWT图形验证码
    POJ 2932 Coneology计算最外层圆个数
    POJ1127 Jack Straws
    求逆序对
    P3809 【模板】后缀排序
    匈牙利算法
    POJ2976 Dropping tests
    字符串哈希
    zkw费用流
    最大流Dinic算法
  • 原文地址:https://www.cnblogs.com/iat14/p/11228201.html
Copyright © 2011-2022 走看看