跳到正文

剪贴板

剪贴板 4w2x1fa4

原文
剪贴板信息

剪贴板信息

收录
更新

Jason331 的 IO 模板

C++
#define END __attribute__((destructor))
typedef long long ll;

namespace //并不支持字符串
{
    constexpr int PSIZ = 40,ISIZ = 1 << 16,OSIZ = ISIZ;
    char ibuf[ISIZ],obuf[OSIZ],st[PSIZ];
    char *ip1 = ibuf,*ip2 = ibuf,*outp1 = obuf,*const outp2 = obuf + OSIZ,ltop;
    inline END void flush() {fwrite(obuf,1,outp1 - obuf,stdout);outp1 = obuf;}
    inline char getc() {if(ip1 == ip2) ip2 = (ip1 = ibuf) + fread(ibuf,1,ISIZ,stdin);return ip1 == ip2?-1:*ip1++;}
    inline void putc(char c) {*outp1++ = c;if(outp1 == outp2) flush();}
    template <typename T> inline void read(T &x) {bool flag = false;char c;for(c = getc();c < '0' && c != '-';c = getc());if(c == '-') flag = true,c = getc();for(x = 0;c >= '0';c = getc()) x = x * 10 + (c ^ '0');if(flag) x = -x;}
    #pragma GCC diagnostic push
    #pragma GCC diagnostic ignored "-Wchar-subscripts"
    template <typename T> inline void write(T x) {if(x < 0) putc('-'),x = -x;ltop = 0;do st[ltop++] = char(x % 10 ^ '0');while(x /= 10);while(ltop--) putc(st[ltop]);}
    #pragma GCC diagnostic pop
    template <typename T,typename... Ts> inline void read(T &x,Ts&... other) {read(x);read(other...);}
    #pragma GCC diagnostic push
    #pragma GCC diagnostic ignored "-Wunused-parameter"
    template <typename T> inline void write(char gap,T x) {write(x);}
    #pragma GCC diagnostic pop
    template <typename T,typename... Ts> inline void write(char gap,T x,Ts... other) {write(x),putc(gap);write(gap,other...);}
    inline int readint() {int x;read(x);return x;}
    inline int readll() {ll x;read(x);return x;}
}

使用样例

C++
write(' ',readint(),readll()); // 读入一个 int 和一个 long long 并输出,用空格隔开
short z;
int x;
ll y;
read(x,y,z);
write('\n',x,y,z);
// 读入一个(或多个) 整数,存入变量中,并输出,用换行符隔开