code:
#include <bits/stdc++.h>
using namespace std;
int len, xh, xg;
char c;
string s;
void eleven()
{
int W = 0, L = 0;
for(int i = 0; i < len; i++)
{
if(s[i] == 'W')
W++;
else
L++;
if((W >= 11 && W - L >= 2) || (L >= 11 && L - W >= 2))
{
printf("%d:%d\n", W, L);
W = L = 0;
}
}
printf("%d:%d\n\n", W, L);
}
void twenty_one()
{
int W = 0, L = 0;
for(int i = 0; i < len; i++)
{
if(s[i] == 'W')
W++;
else
L++;
if((W >= 21 && W > L && W - L >= 2) || (L >= 21 && L > W && L - W >= 2))
{
printf("%d:%d\n", W, L);
W = L = 0;
}
}
printf("%d:%d", W, L);
}
int main()
{
while(1)
{
scanf("%c", &c);
if(c == 'E')
break;
if(c == '\n')
continue;
s += c;
}
len = s.length();
printf("%d\n", len);
eleven();
twenty_one();
return 0;
}
第一个和最后一个A了