C++ 代码压行工具

启发

个人特别喜欢压行

MivikAC 牛 的 C++ 代码压行机启发,改写增强了 Mivik 的 js 脚本,增加了按行字符数压行的功能,并在 Github 上进行了开源

使用

链接

宽度设为小于 $2$ 的时候即压成一行,否则值必须大于等于 $2$。

如果你设为其他的数值,它会默认给你压成宽度为 $2$ 的效果。

可以用来压板子,也可以用来防 Hack!

注意:

  • 压行或清空后,编辑器无法撤回代码!
  • 如果你有类似 std::pair<int,std::pair<int,int> > 这样的写法,压行机会自动把两个 > 中间的空格压掉,此时在 C++11 以下版本中会编译错误。

Enjoy it!

示例

如这样的一个 FastIO 板子:

namespace FastIO{
    static const int BUFSIZE__=(1<<20)+1;
    static char Ibuf__[BUFSIZE__],*I1__=Ibuf__,*I2__=Ibuf__,Obuf__[BUFSIZE__],*O1__=Obuf__,*O2__=O1__+BUFSIZE__-1;
    static int ST__[55],Top__;
    inline void flush(){fwrite(Obuf__,1,O1__-Obuf__,stdout),O1__=Obuf__;}
    struct flusher__{~flusher__(){flush();}}IO__;
    inline char getch(){return I1__==I2__&&(I2__=(I1__=Ibuf__)+fread(Ibuf__,1,BUFSIZE__,stdin),I1__==I2__)?EOF:*I1__++;}
    inline void putch(char Ch__){*O1__++=Ch__,(O1__==O2__)?flush():void();}
    inline void getstr(char *S__){
        char Ch__=getch();
        int cnt__=0;
        for (;!isgraph(Ch__);Ch__=getch());
        for (;isgraph(Ch__);Ch__=getch())
            S__[cnt__++]=Ch__;
        S__[cnt__]=0;
    }
    inline void putstr(const char *S__){
        int Len__=strlen(S__);
        for (int i__=0;i__<Len__;++i__)
            putch(S__[i__]);
    }
    template<typename Var__>
    inline Var__ read(){
        register Var__ Res__=0,W__=1;
        register char Ch__=getch();
        for (;Ch__<'0'||Ch__>'9';Ch__=getch())
            if (Ch__=='-') W__=-1;
        for (;Ch__<='9'&&Ch__>='0';Ch__=getch())
            Res__=(Res__<<3)+(Res__<<1)+(Ch__^48);
        return Res__*W__;
    }
    inline double readDB(){
        register double ResB__=0,Cnt__=1;
        register char Ch__=getch();
        register int ResA__=0,W__=1;
        if (Ch__!='.'){
            for (;Ch__<'0'||Ch__>'9';Ch__=getch())
                if (Ch__=='-') W__=-1;
            for (;Ch__<='9'&&Ch__>='0';Ch__=getch())
                ResA__=(ResA__<<3)+(ResA__<<1)+(Ch__^48);
            if (Ch__!='.') return ResA__*W__;
        }
        Ch__=getch();
        for (;Ch__<='9'&&Ch__>='0';Ch__=getch())
            ResB__+=(Ch__^48)*(Cnt__*=0.1);
        return (ResA__+ResB__)*W__;
    }
    template<typename Var__>
    inline void write(register Var__ Num__,const char Ch__='\0'){
        if (!Num__) putch('0');
        if (Num__<0) putch('-'),Num__=-Num__;
        for (;Num__;ST__[++Top__]=Num__%10+'0',Num__/=10);
        for (;Top__;putch(ST__[Top__--]));
        if (Ch__!='\0') putch(Ch__);
    }
}

可以被压成这样(宽度:$-1$):

namespace FastIO{static const int BUFSIZE__=(1<<20)+1;static char Ibuf__[BUFSIZE__],*I1__=Ibuf__,*I2__=Ibuf__,Obuf__[BUFSIZE__],*O1__=Obuf__,*O2__=O1__+BUFSIZE__-1;static int ST__[55],Top__;inline void flush(){fwrite(Obuf__,1,O1__-Obuf__,stdout),O1__=Obuf__;}struct flusher__{~flusher__(){flush();}}IO__;inline char getch(){return I1__==I2__&&(I2__=(I1__=Ibuf__)+fread(Ibuf__,1,BUFSIZE__,stdin),I1__==I2__)?EOF:*I1__++;}inline void putch(char Ch__){*O1__++=Ch__,(O1__==O2__)?flush():void();}inline void getstr(char*S__){char Ch__=getch();int cnt__=0;for(;!isgraph(Ch__);Ch__=getch());for(;isgraph(Ch__);Ch__=getch())S__[cnt__++]=Ch__;S__[cnt__]=0;}inline void putstr(const char*S__){int Len__=strlen(S__);for(int i__=0;i__<Len__;++i__)putch(S__[i__]);}template<typename Var__>inline Var__ read(){register Var__ Res__=0,W__=1;register char Ch__=getch();for(;Ch__<'0'||Ch__>'9';Ch__=getch())if(Ch__=='-')W__=-1;for(;Ch__<='9'&&Ch__>='0';Ch__=getch())Res__=(Res__<<3)+(Res__<<1)+(Ch__^48);return Res__*W__;}inline double readDB(){register double ResB__=0,Cnt__=1;register char Ch__=getch();register int ResA__=0,W__=1;if(Ch__!='.'){for(;Ch__<'0'||Ch__>'9';Ch__=getch())if(Ch__=='-')W__=-1;for(;Ch__<='9'&&Ch__>='0';Ch__=getch())ResA__=(ResA__<<3)+(ResA__<<1)+(Ch__^48);if(Ch__!='.')return ResA__*W__;}Ch__=getch();for(;Ch__<='9'&&Ch__>='0';Ch__=getch())ResB__+=(Ch__^48)*(Cnt__*=0.1);return(ResA__+ResB__)*W__;}template<typename Var__>inline void write(register Var__ Num__,const char Ch__='\0'){if(!Num__)putch('0');if(Num__<0)putch('-'),Num__=-Num__;for(;Num__;ST__[++Top__]=Num__%10+'0',Num__/=10);for(;Top__;putch(ST__[Top__--]));if(Ch__!='\0')putch(Ch__);}}

也可以被压成这样:(宽度:$80$)

namespace FastIO{static const int BUFSIZE__=(1<<20)+1;static char Ibuf__[BUFSIZ\
E__],*I1__=Ibuf__,*I2__=Ibuf__,Obuf__[BUFSIZE__],*O1__=Obuf__,*O2__=O1__+BUFSIZ\
E__-1;static int ST__[55],Top__;inline void flush(){fwrite(Obuf__,1,O1__-Obuf__\
,stdout),O1__=Obuf__;}struct flusher__{~flusher__(){flush();}}IO__;inline char \
getch(){return I1__==I2__&&(I2__=(I1__=Ibuf__)+fread(Ibuf__,1,BUFSIZE__,stdin),\
I1__==I2__)?EOF:*I1__++;}inline void putch(char Ch__){*O1__++=Ch__,(O1__==O2__)\
?flush():void();}inline void getstr(char*S__){char Ch__=getch();int cnt__=0;for\
(;!isgraph(Ch__);Ch__=getch());for(;isgraph(Ch__);Ch__=getch())S__[cnt__++]=Ch_\
_;S__[cnt__]=0;}inline void putstr(const char*S__){int Len__=strlen(S__);for(in\
t i__=0;i__<Len__;++i__)putch(S__[i__]);}template<typename Var__>inline Var__ r\
ead(){register Var__ Res__=0,W__=1;register char Ch__=getch();for(;Ch__<'0'||Ch\
__>'9';Ch__=getch())if(Ch__=='-')W__=-1;for(;Ch__<='9'&&Ch__>='0';Ch__=getch())\
Res__=(Res__<<3)+(Res__<<1)+(Ch__^48);return Res__*W__;}inline double readDB(){\
register double ResB__=0,Cnt__=1;register char Ch__=getch();register int ResA__\
=0,W__=1;if(Ch__!='.'){for(;Ch__<'0'||Ch__>'9';Ch__=getch())if(Ch__=='-')W__=-1\
;for(;Ch__<='9'&&Ch__>='0';Ch__=getch())ResA__=(ResA__<<3)+(ResA__<<1)+(Ch__^48\
);if(Ch__!='.')return ResA__*W__;}Ch__=getch();for(;Ch__<='9'&&Ch__>='0';Ch__=g\
etch())ResB__+=(Ch__^48)*(Cnt__*=0.1);return(ResA__+ResB__)*W__;}template<typen\
ame Var__>inline void write(register Var__ Num__,const char Ch__='\0'){if(!Num_\
_)putch('0');if(Num__<0)putch('-'),Num__=-Num__;for(;Num__;ST__[++Top__]=Num__%\
10+'0',Num__/=10);for(;Top__;putch(ST__[Top__--]));if(Ch__!='\0')putch(Ch__);}}

还可以被压成这样:(宽度:$2$)

Code

都是可以正常使用的。

求测

如果被你玩出了 bug,欢迎来本项目地址提 issue!

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇