BlackWuKong @ 2024-07-23 15:09:05
#include<bits/stdc++.h>
using namespace std;
int f[2]={11,21};
int a[25*2500+10],n=0;
int main(){
char tmp;
while (1){
cin>>tmp;
if (tmp=='E') break;
else if (tmp=='W') a[n++]=1;
else if (tmp=='L') a[n++]=0;
}
for (int i=0;i<2;i++){
int w=0,l=0;
for (int j=0;j<n;j++){
w+=a[j],l+=1-a[j];
if (max(l,w)>=f[i]&&abs(w-1)>=2){
cout<<w<<":"<<l<<endl;
w=l=0;
}
}
cout<<w<<":"<<l<<endl;
cout<<endl;
}
return 0;
}
by skyqiu @ 2024-07-29 09:12:35
@lanlingxuan 深基的l(字母)和1(数字)确实难分. 你第17行有问题
#include<bits/stdc++.h>
using namespace std;
int f[2]={11,21};
int a[25*2500+10],n=0;
int main(){
char tmp;
while (1){
cin>>tmp;
if (tmp=='E') break;
else if (tmp=='W') a[n++]=1;
else if (tmp=='L') a[n++]=0;
}
for (int i=0;i<2;i++){
int w=0,l=0;
for (int j=0;j<n;j++){
w+=a[j],l+=1-a[j];
if (max(l,w)>=f[i]&&abs(w-l)>=2){//算的是双方差距大于2,你写了数字一
cout<<w<<":"<<l<<endl;
w=l=0;
}
}
cout<<w<<":"<<l<<endl;
cout<<endl;
}
return 0;
}
//AC