只有十分!!大佬捞捞
查看原帖
只有十分!!大佬捞捞
1461112
Bettieee楼主2024/12/1 19:42

#####只有十分我已经把读入只限定在L和W里面了,这道题还有其他一易错点吗??呜呜呜救救孩子,大佬捞捞

#include<stdio.h>
#include<string.h>
#include<math.h>
#define N 80000
int w=0,l=0;

int min(int a,int b){
    return a<b?a:b;
}
char str[N];
char p[2502][26];
int len;
void ele(int n);
void twn(int n);
int main(void){
int i,j;
len=0;
    for(i=0;i<N;i++){
        char k;
        scanf("%c",&k);
        if(k=='\n')continue;
        else if(k=='E')break;
        else if(k=='L')str[len++]=k;
        else if(k=='W')str[len++]=k;
        else continue;
    }
    len=strlen(str);
    ele(0);
    putchar('\n');
    twn(0);//从零开始的查找数组
    return 0;
}
void ele(int n){
  do{
      if(str[n]=='L')l++;
      else if(str[n]=='W')w++;
      n++;
      if(l+w>=11&&abs(l-w)>=2){printf("%da:%d\n",w,l);l=0;w=0;}
      else if(n==len){printf("%d:%d\n",w,l);l=0;w=0;}

  }while(n<len);
  //return 0;
}

void twn(int n){
  do{
      if(str[n]=='L')l++;
      else if(str[n]=='W')w++;
      n++;
      if(l+w>=21&&abs(l-w)>=2){printf("%d:%d\n",w,l);l=0;w=0;}
      else if(n==len){printf("%d:%d\n",w,l);l=0;w=0;}

  }while(n<len);

}

2024/12/1 19:42
加载中...