求助不定参数
  • 板块学术版
  • 楼主Isshiki·Iroha
  • 当前回复6
  • 已保存回复6
  • 发布时间2021/10/19 19:01
  • 上次更新2023/11/4 03:16:25
查看原帖
求助不定参数
414386
Isshiki·Iroha楼主2021/10/19 19:01

这是可以传入不定参数的快读

    template<typename T>inline void read(T& x) {
        x=0;int f=1;
        char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=~f+1;ch=getchar();}
        while (isdigit (ch)) {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
        x*=f;
    }
    template <typename T,typename... Args> inline void read(T& x, Args&... args) {
        read(x);
        read(args...);
    }

如果我要这么写

    inline void read(int& x) {
        x=0;int f=1;
        char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=~f+1;ch=getchar();}
        while (isdigit (ch)) {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
        x*=f;
    }

那我改怎么写?

2021/10/19 19:01
加载中...