#1#8#10RE

P1042 [NOIP2003 普及组] 乒乓球

yinjunrui @ 2024-10-25 14:55:28

为什么会RE,数组已经开的够大了吧qwq

#include<bits/stdc++.h>
using namespace std;
char c[1000005],top;
void jf(int x){
    int a=0,b=0;
    for(int i=1;i<=top;i++){
        if(c[i]=='W'){
            a++;
        }else if(c[i]=='L'){
            b++;
        }
        if((a>=x||b>=x)&&abs(a-b)>=2){
            cout<<a<<':'<<b<<endl;
            a=0,b=0;
        }
    }
    cout<<a<<':'<<b;
} 
int main(){
    char a;
    while(cin>>a){
        if(a!='E'){
            ++top;
            c[top]=a;
        }else{
            break;
        }
    }
    jf(11);
    cout<<endl<<endl;
    jf(21);
    return 0;
}

by claoday @ 2024-10-25 15:25:52

char top

top 变量改成 int 类型!

求关


by claoday @ 2024-10-25 15:26:13

@fantexi


by yinjunrui @ 2024-10-25 15:51:03

谢谢,已关


by yinjunrui @ 2024-10-25 15:51:23

@claoday 已关


|