SHILINM @ 2024-10-10 16:44:02
20分,求调。输出结果和测试点2一样,但判错,不知道是哪里出问题了```cpp
using namespace std;
#include<iostream>
#include<cstdio>
#include<sstream>
int main()
{
char c;
int w1=0,w2=0,l1=0,l2=0;
stringstream s1,s2;
while(1)
{
c=getchar();
if (c=='\n')
continue;
else if(c=='E')
{
s1<<w1<<":"<<l1<<endl;
s2<<w2<<":"<<l2<<endl;
break;
}
if(c=='W')
w1++,w2++;
else
l1++,l2++;
if((w1>=11||l1>=11)&&(w1-l1>=2||l1-w1>=2))
{
s1<<w1<<":"<<l1<<endl;
w1=0;l1=0;
}
if((w2>=21||l2>=21)&&(w2-l2>=2||l2-w2>=2))
{
s2<<w2<<":"<<l2<<endl;
w2=0;l2=0;
}
}
cout<<s1.str()<<endl<<s2.str();
return 0;
}