##c语言40分
查看原帖
##c语言40分
798029
zhazhaqi77楼主2022/11/13 22:40

写了两三个小时了孩子心态有点崩

#include<stdio.h>
int main()
{
    char str[70000];
    int i;
    for(i=0;;i++){
        scanf("%c",&str[i]);
        if(str[i]=='E'){break;}
    }
    int n=1;
    int w1=0,l1=0;
    for(i=0;str[i]!='E';i++){
        if(str[i]=='W'){
            w1++;
        }if(str[i]=='L'){
            l1++;
        }
        if((w1==11||l1==11) && ((w1-l1)>=2||(l1-w1)>=2)){
            printf("%d:%d\n",w1,l1);
            w1=0;l1=0;
        }else if((w1>11||l1>11)){
            if((w1-l1)>=2||(l1-w1)>=2)
                printf("%d:%d\n",w1,l1);
                w1=0;l1=0;
            }
            if(str[i+1]=='E'){
                printf("%d:%d\n",w1,l1);
            }
    }
    w1=0;l1=0;
    for(i=0;str[i]!='E';i++){
        if(str[i]=='W'){
            w1++;
        }if(str[i]=='L'){
            l1++;
        }
        if((w1==21||l1==21) && ((w1-l1)>=2||(l1-w1)>=2)){
            printf("%d:%d\n",w1,l1);
            w1=0;l1=0;
        }else if((w1>21||l1>21)){
            if((w1-l1)>=2||(l1-w1)>=2)
                printf("%d:%d\n",w1,l1);
                w1=0;l1=0;
            }if(str[i+1]=='E'){
                printf("%d:%d\n",w1,l1);
            }
    }
    return 0;
}
2022/11/13 22:40
加载中...