快写代码求调,输出全是0无限循环
  • 板块学术版
  • 楼主lwx20211103
  • 当前回复13
  • 已保存回复13
  • 发布时间2022/12/31 19:56
  • 上次更新2023/10/24 05:59:46
查看原帖
快写代码求调,输出全是0无限循环
727008
lwx20211103楼主2022/12/31 19:56
struct writer
    {
        template <typename T> T &operator<<(T x)
        {
            static_assert(is_integral<T>::value, "only interger!");
            int sta[50];
            int tp = 0;
            do
            {
                sta[tp++] = x % 10;x /= 10;
            } while (x);
            while (tp) putchar(sta[--tp] + '0');
        }
    } write;

调用

int x = 48;
write << x;
2022/12/31 19:56
加载中...