10分求调!

P1042 [NOIP2003 普及组] 乒乓球

dfg_mmnd @ 2024-10-07 10:03:58

#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
    getline(cin,s,'E');
    int sy_h=0,sy_d=0,js=0;
    while(0){
        if(s[js]=='E'){
            break;
        }
        if(s[js]=='W'){
            sy_h++;
        }else{
            sy_d++;
        }
        if(sy_h==11||sy_d==11){
            cout<<sy_h<<':'<<sy_d<<endl;
            sy_h=0;
            sy_d=0;
        }
    }
    cout<<sy_h<<':'<<sy_d<<endl;
    sy_h=0;
    sy_d=0;
    cout<<endl;
    while(0){
        if(s[js]=='E'){
            break;
        }
        if(s[js]=='W'){
            sy_h++;
        }else{
            sy_d++;
        }
        if(sy_h==21||sy_d==21){
            cout<<sy_h<<':'<<sy_d<<endl;
            sy_h=0;
            sy_d=0;
        }
    }
    cout<<sy_h<<':'<<sy_d<<endl;
    return 0;
}

by lsd110504 @ 2024-10-07 10:08:01

16回提交才过《我的》

你看看吧
#include <iostream>
using namespace std;
const int zm=62526;
int main()
{
    char a[zm];
    int i=1,hh=0,ll=0,ans=0,bns=0;
    while(cin>>a[i])
    {
        ans=hh;
        bns=ll;
        if(a[i]=='E')
        break;
        if((ans>=11||bns>=11)&&(ans-bns>=2||bns-ans>=2))
        {
            cout<<ans<<":"<<bns<<endl;
            ans=0;
            bns=0;
            hh=0;
            ll=0;
         } 
        if(a[i]=='W')
        hh++;
        else if(a[i]=='L')
        ll++;
        i++;
    }
    if(hh||ll)
    cout<<hh<<":"<<ll<<endl;
     if(hh==0&&ll==0||(hh==11||ll==11))
    cout<<0<<":"<<0<<endl;
    cout<<endl;
    i=1;
    hh=0;
    ll=0;
    ans=0;
    bns=0;
    while(a[i])
    {
        if(a[i]=='E')
        break;
        ans=hh;
        bns=ll;
        if((ans>=21||bns>=21)&&(ans-bns>=2||bns-ans>=2))
        {
            cout<<ans<<":"<<bns<<endl;
            ans=0;
            bns=0;
            hh=0;
            ll=0;
         } 
        if(a[i]=='W')
        hh++;
        else if(a[i]=='L')
        ll++;
        i++;
    }
    if(hh||ll)
    cout<<hh<<":"<<ll<<endl;
    else if(hh==0&&ll==0)
    cout<<hh<<":"<<ll<<endl;
    return 0;
 } 

by dfg_mmnd @ 2024-10-07 14:33:37

@lsd110504 谢谢,已关


|