关于最后一组数据,我快读挂了这件事

P4114 Qtree1

Muel_imj @ 2022-01-12 11:31:20

刚开始快读迷之挂掉:

inline char gc(){
    static char buf[1<<20],*p1,*p2;
    if(p1==p2){p1=buf,p2=buf+fread(buf,1,1<<20,stdin);if(p1==p2)return EOF;}
    return *p1++;
}
inline void reads(char *str){
    int len=0;char c=gc();
    while(c=='\n'||c==' ')c=gc();
    while(c!='\n'&&c!=' '){str[len++]=c;c=gc();}
    str[len]='\0';
}

然后在reads第二个while加了个 &&!=EOF 就过了 最后一组数据末?


by Aftglw @ 2022-02-11 17:26:55

orz!


|