Leaf59 @ 2024-09-03 20:39:56
#include<bits/stdc++.h>
using namespace std;
string s1;
bool f=false;
int main(){
cin>>s1;
int len=s1.length();
int sum=0,sum2=0;
for(int i=0;i<len;i++){
if(s1[i]=='E') break;
if((sum>=11&&sum-sum2>=2)||(sum2>=11&&sum2-sum>=2)){
f=true;
printf("%d:%d",sum,sum2);
sum=sum2=0;
cout<<endl;
}
if(s1[i]=='W') sum++;
else if(s1[i]=='L')sum2++;
}
if(sum||sum2){
f=true;
printf("%d:%d",sum,sum2);
sum=sum2=0;
cout<<endl;
}
if(!f) cout<<"0:0\n";
f=false;
cout<<endl;
for(int i=0;i<len;i++){
if(s1[i]=='E') break;
if((sum>=21&&sum-sum2>=2)||(sum2>=21&&sum2-sum>=2)){
f=true;
printf("%d:%d",sum,sum2);
sum=sum2=0;
cout<<endl;
}
if(s1[i]=='W') sum++;
else if(s1[i]=='L')sum2++;
}
if(sum||sum2){
f=true;
printf("%d:%d",sum,sum2);
sum=sum2=0;
}
if(!f) cout<<"0:0";
return 0;
}
by auspicious2013 @ 2024-09-03 20:47:48
为什么我看不懂你代码
#include<bits/stdc++.h>
using namespace std;
string s,s1;
int a,b;
int main(){
while(cin>>s1){
s+=s1;
}
for(int i=0;s[i]!='E';i++){
if(s[i]=='W'){
a++;
}
if(s[i]=='L'){
b++;
}
if(a>=11 && a-b>=2 || b>=11 && b-a>=2){
cout<<a<<":"<<b<<endl;
a=b=0;
}
}
cout<<a<<":"<<b<<endl;
cout<<endl;
a=b=0;
for(int i=0;s[i]!='E';i++){
if(s[i]=='W'){
a++;
}
if(s[i]=='L'){
b++;
}
if(a>=21 && a-b>=2 || b>=21 && b-a>=2){
cout<<a<<":"<<b<<endl;
a=b=0;
}
}
cout<<a<<":"<<b;
return 0;
}