jason2024 @ 2024-06-28 17:12:09
#include<bits/stdc++.h>
using namespace std;
string a[100000000];
int b=0,c=0;
int main(){
for(int i=1;;++i){
cin>>a[i];
if(a[i]=="E") break;
}
for(int i=1;;++i){
if(a[i]=="W") b++;
if(a[i]=="L") c++;
if((b>=11||c>=11)&&abs(c-b)>=2){
cout<<b<<":"<<c<<endl;
b=0;
c=0;
}
if(a[i]=="E"){
cout<<b<<":"<<c<<endl<<endl;
b=0;
c=0;
break;
}
}
for(int i=1;;++i){
if(a[i]=="W") b++;
if(a[i]=="L") c++;
if((b>=21||c>=21)&&abs(c-b)>=2){
cout<<b<<":"<<c<<endl;
b=0;
c=0;
}
if(a[i]=="E"){
cout<<b<<":"<<c;
break;
}
}
return 0;
}
求助大佬
by zts201210 @ 2024-06-28 17:22:44
string a[100000000];
这里有错误,有两种方案
//1.
string a;
//2.
char a[100000000];
by huangshuchang @ 2024-06-28 17:41:13
#include<bits/stdc++.h>
using namespace std;
char s[100010];
int cnt=0;
void tf(int x){
int n=0,m=0;
for(int i=0;i<cnt;i++){
if(s[i]=='W') n++;
if(s[i]=='L') m++;
if((n>=x||m>=x)&&abs(n-m)>=2){
cout<<n<<":"<<m<<endl;
n=0;
m=0;
}
}
cout<<n<<":"<<m<<endl;
}
int main(){
char ch;
while(1){
cin>>ch;
if(ch=='W'||ch=='L'){
s[cnt++]=ch;
}
if(ch=='E'){
break;
}
}
tf(11);cout<<endl;tf(21);
}
@jason2024
by huangshuchang @ 2024-06-28 17:42:43
求关注
by jason2024 @ 2024-06-28 22:58:42
@huangshuchang 已解出,谢谢 已关注