- 乒乓球
- 2019-09-28 00:57:52 @
#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 条评论
-
Ven_ LV 6 @ 2019-10-22 16:51:59
我就第一个和第十个点过了
-
2019-09-30 16:21:32@
常规操作
- 1