interory @ 2024-07-11 09:57:51
#include <bits/stdc++.h>
using namespace std;
int main(){
char arr[114514]={};
int a=0,l=0,w=0,b;
while(arr[a]!='E'){
a++;
cin>>arr[a];
}
for(int i=1;i<a;i++){
if(w>=11 || l>=11){
if(abs(w-l)<2){
b=123;
}
else{
cout<<w<<':'<<l<<endl;
w=0,l=0;
}
}
if(arr[i]=='W'){
w++;
}
else if(arr[i]=='L'){
l++;
}
}
cout<<w<<':'<<l<<endl;
cout<<endl;
w=0,l=0;
for(int i=1;i<a;i++){
if(w>=21 || l>=21){
if(abs(w-l)<2){
b=123;
}
else{
cout<<w<<':'<<l<<endl;
w=0,l=0;
}
}
if(arr[i]=='W'){
w++;
}
else if(arr[i]=='L'){
l++;
}
}
cout<<w<<':'<<l;
return 0;
}
by taoqiniu @ 2024-07-11 10:44:54
@interory 少加一个= for少循环一次
by limuchudsb @ 2024-07-18 09:12:01
你输入WWWWWWWWWWWEadfadf;jadf
试一试
by limuchudsb @ 2024-07-18 09:14:55
输入WWWWWWWWWWWEadfadf;jadf的答案是
11:0
0:0
11:0
by lznxes @ 2024-07-18 20:23:34
其实数据有问题,先这么写着
by limuchudsb @ 2024-07-19 12:11:19
c```cpp
#include <bits/stdc++.h>
using namespace std;
int main(){
char arr[114514]={};
int a=1,l=0,w=0,b;
while(cin>>arr[a] && arr[a]!='E'){
a++;
}
for(int i=1;i<=a;i++){
if(w>=11 || l>=11){
if(abs(w-l)<2){
b=123;
}
else{
cout<<w<<':'<<l<<endl;
w=0,l=0;
}
}
if(arr[i]=='W'){
w++;
}
else if(arr[i]=='L'){
l++;
}
}
cout<<w<<':'<<l<<endl;
cout<<endl;
w=0,l=0;
for(int i=1;i<=a;i++){
if(w>=21 || l>=21){
if(abs(w-l)<2){
b=123;
}
else{
cout<<w<<':'<<l<<endl;
w=0,l=0;
}
}
if(arr[i]=='W'){
w++;
}
else if(arr[i]=='L'){
l++;
}
}
cout<<w<<':'<<l;
return 0;
}
by limuchudsb @ 2024-07-19 12:13:06
for(int i=1;i<a;i++)改成for(int i=1;i<=a;i++)