MM_GG @ 2024-10-06 20:23:35
#include <bits/stdc++.h>
using namespace std;
int s[1005][1005];
int main()
{
char n;
int s1=0,x1=0,i=1;
while(1)
{
cin>>n;
if(n=='E') break;
if(n=='W')
{
s1++;
s[i][1]++;
}
else
{
x1++;
s[i][2]++;
}
if((s1-x1>=2||x1-s1>=2)&&(x1>=11||s1>=11))
{
cout<<s1<<':'<<x1<<'\n';
s1=0;
x1=0;
}
if((s[i][1]-s[i][2]>=2||s[i][2]-s[i][1]>=2)&&(s[i][1]>=21||s[i][2]>=21)) i++;
}
if(s1>0||x1>0) cout<<s1<<':'<<x1<<'\n'<<'\n';
else cout<<'\n';
for(int k=1; k<=i; k++)
{
cout<<s[k][1]<<':'<<s[k][2]<<'\n';
}
return 0;
}
by binyage @ 2024-10-07 14:40:05
#include<bits/stdc++.h>
using namespace std;
char s[70000],ch;
int id=1,w=0,l=0;
int main()
{
while(cin>>ch)
{
if(ch=='E')
{
break;
}
else
{
s[id++]=ch;
}
}
for(int i=1;i<id;i++)
{
if(s[i]=='W')
{
w++;
}
else if(s[i]=='L')
{
l++;
}
if((w==11&&w-l>=2)||(l==11&&l-w>=2))
{
cout<<w<<":"<<l<<endl;
w=l=0;
}
else if((w>=11&&w-l>=2)||(l>=11&&l-w>=2))
{
cout<<w<<":"<<l<<endl;
w=l=0;
}
}
cout<<w<<":"<<l<<endl<<endl;
w=l=0;
for(int i=1;i<id;i++)
{
if(s[i]=='W')
{
w++;
}
else if(s[i]=='L')
{
l++;
}
if((w==21&&w-l>=2)||(l==21&&l-w>=2))
{
cout<<w<<":"<<l<<endl;
w=l=0;
}
else if((w>=21&&w-l>=2)||(l>=21&&l-w>=2))
{
cout<<w<<":"<<l<<endl;
w=l=0;
}
}
cout<<w<<":"<<l;
return 0;
}
by binyage @ 2024-10-07 14:40:34
看看吧。
by MM_GG @ 2024-10-13 15:28:24
THANK