为什么我第一个点最后一个点过不了,有0:0的啊?

#include<stdio.h>
#include<stdlib.h>
#include<iostream>

#include<cstring>
using namespace std;



void pingpeng()
{
    char match[100000];
    char input[20];
    int t = 0;
    int p = 0;
    bool endflag = false;
    while (1)
    {
        input[t] = cin.get();

        if (input[t] == 'W' || input[t] == 'L')
        {
            match[p] = input[t];
            p++;
        }
        if (input[t] == 'E')
        {
            break;
        }
        t++;
    }

    /*  for (int i = 0; i < input.length(); i++)
    {
    if (input[i] == 'W'||input[i]=='L')
    {
    match += input[i];
    }
    if (input[i] == 'E')
    {
    match += input[i];
    endflag = true;
    break;
    }
    if (endflag == true)
    {
    break;
    }
    }
    */

    int win = 0, lose = 0;
    int games = 0;
    int chars = 0;
    endflag = false;
    while (chars < strlen(match))
    {
        while (abs(win - lose) < 2 || (win<11 && lose<11))
        {
            if (match[chars] == 'W')
            {
                win++;
                chars++;
            }
            else if (match[chars] == 'L')
            {
                lose++;
                chars++;
            }
            else
            {
                if (win != 0 || lose != 0)
                {
                    cout << win << ":" << lose << '\n';
                }
                endflag = true;
                break;
            }
        }
        if (endflag == true)
        {
            break;
        }
        else
        {
            if (win != 0 || lose != 0)
            {
                cout << win << ":" << lose << '\n';
            }

            win = 0;
            lose = 0;
        }
        //chars++;
    }

    cout << '\n';

    chars = 0;
    win = 0;
    lose = 0;
    endflag = false;

    while (chars < strlen(match))
    {
        while (abs(win - lose) < 2 || (win<21 && lose<21))
        {
            if (match[chars] == 'W')
            {
                win++;
                chars++;
            }
            else if (match[chars] == 'L')
            {
                lose++;
                chars++;
            }
            else
            {
                if (win != 0 || lose != 0)
                {
                    cout << win << ":" << lose << '\n';
                }

                endflag = true;
                break;
            }
        }
        if (endflag == true)
        {
            break;
        }
        else
        {
            if (win != 0 || lose != 0)
            {
                cout << win << ":" << lose << '\n';
            }

            win = 0;
            lose = 0;
        }
        //chars++;
    }

}
int main(void)
{
    pingpeng();
    return 0;
}

2 条评论

  • @ 2019-10-22 16:51:59

    我就第一个和第十个点过了

  • @ 2019-09-30 16:21:32

    常规操作

  • 1

信息

ID
1217
难度
7
分类
字符串 点击显示
标签
递交数
18717
已通过
4282
通过率
23%
被复制
33
上传者