auspicious2013 @ 2024-08-27 11:14:26
如题,不知为啥。 (c++)
#include<bits/stdc++.h>
using namespace std;
string s,s1;
int a,b,cnt;
int main(){
while(cin>>s1){
s+=s1;
}
int len=s.length();
for(int i=0;i<len;i++){
cnt++;
if(s[i]=='E'){
cout<<a<<":"<<b<<endl;
a=b=cnt=0;
break;
}
if(s[i]=='W'){
a++;
}else{
b++;
}
if(cnt==11){
cout<<a<<":"<<b<<endl;
a=b=cnt=0;
}
}
cout<<endl;
for(int i=0;i<len;i++){
cnt++;
if(s[i]=='E'){
cout<<a<<":"<<b;
break;
}
if(s[i]=='W'){
a++;
}else{
b++;
}
if(cnt==21){
cout<<a<<":"<<b<<endl;
a=b=cnt=0;
}
}
return 0;
}
by 违规用户名Jx9)zIu @ 2024-08-27 11:17:16
#include<bits/stdc++.h>
using namespace std;
int main(){
string s1;
string s2;
while(cin>>s2){
s1+=s2;
}
int t1=0,t2=0;
for(int i=0;s1[i]!='E';i++){
if(s1[i]=='W'){
t1++;
}
if(s1[i]=='L'){
t2++;
}
if(t1>=11&&t1-t2>=2||t2>=11&&t2-t1>=2){
cout<<t1<<":"<<t2<<endl;
t1=0;
t2=0;
}
}
cout<<t1<<":"<<t2<<endl;
cout<<endl;
t1=0;
t2=0;
for(int i=0;s1[i]!='E';i++){
if(s1[i]=='W'){
t1++;
}
if(s1[i]=='L'){
t2++;
}
if(t1>=21&&t1-t2>=2||t2>=21&&t2-t1>=2){
cout<<t1<<":"<<t2<<endl;
t1=0;
t2=0;
}
}
cout<<t1<<":"<<t2;
return 0;
}
我的代码 @auspicious2013
求关
by Yxy7952 @ 2024-08-27 11:18:30
@auspicious2013 @违规用户名Jx9)zIu
拜托,楼主又不是要你的代码
by shaoningyuan @ 2024-08-27 11:20:16
@auspicious2013 应该不是当cnt=11和21时输出,而是当a或b等于21或11时输出吧(在“E”之前)
by tt12341234 @ 2024-08-27 11:23:15
@auspicious2013 AC代码
#include<bits/stdc++.h>
using namespace std;
char str[100010];
int cnt=0;
void show(int n){
int a=0,b=0;
for(int i=0;i<cnt;i++){
if(str[i]=='W') a++;
if(str[i]=='L') b++;
if((a>=n||b>=n)&&abs(a-b)>=2){
cout<<a<<":"<<b<<endl;
a=b=0;
}
}
cout<<a<<":"<<b<<endl;
}
int main(){
char ss;
while(cin>>ss&&ss!='E'){
if(ss=='W'||ss=='L'){
str[cnt++]=ss;
}
}
show(11);
cout<<endl;
show(21);
}
求关
by haomin423 @ 2024-08-27 11:34:23
#include<bits/stdc++.h>
using namespace std;
char ch[625005];
int main() {
char ch1;
int i;
for(i=1;;i++) {
cin >>ch1;
if(ch1=='E') {
break;
}
ch[i]=ch1;
}
int cnt1=0,cnt2=0;
for(int j=1 ; j <i; j++) {
if(ch[j]=='W') {
cnt1++;
} else {
cnt2++;
}
if(cnt1>=11 || cnt2>=11) {
if(abs(cnt1-cnt2)>=2) {
cout <<cnt1<<":" << cnt2<<endl;
cnt1=0,cnt2=0;
}
}
}
cout<<cnt1<<":"<<cnt2<<endl;
cout<<endl;
cnt1=0,cnt2=0;
for(int j=1 ; j<i; j++) {
if(ch[j]=='W') {
cnt1++;
} else {
cnt2++;
}
if(cnt1>=21 || cnt2>=21) {
if(abs(cnt1-cnt2)>=2) {
cout <<cnt1<<":" << cnt2<<endl;
cnt1=0,cnt2=0;
}
}
}
cout<<cnt1<<":"<<cnt2<<endl;
return 0;
}
by auspicious2013 @ 2024-08-27 11:40:18
@haomin423 @tt12341234 @shaoningyuan @yixingyou @违规用户名Jx9)zIu
thanks,已关。