zoukankan      html  css  js  c++  java
  • 省略的缺省源

    为了避免每段代码前面都有一堆长的吓人的缺省源,现在把缺省源贴在下面,以后的代码里就把这些板子去掉了。

    缺省源的位置在 头文件下方

    #ifdef ONLINE_JUDGE
    #define freopen(a, b, c)
    #endif
    
    typedef long long int ll;
    
    namespace IPT {
      const int L = 1000000;
      char buf[L], *front=buf, *end=buf;
      char GetChar() {
        if (front == end) {
          end = buf + fread(front = buf, 1, L, stdin);
          if (front == end) return -1;
        }
        return *(front++);
      }
    }
    
    template <typename T>
    inline void qr(T &x) {
      char ch = IPT::GetChar(), lst = ' ';
      while ((ch > '9') || (ch < '0')) lst = ch, ch=IPT::GetChar();
      while ((ch >= '0') && (ch <= '9')) x = (x << 1) + (x << 3) + (ch ^ 48), ch = IPT::GetChar();
      if (lst == '-') x = -x;
    }
    
    namespace OPT {
      char buf[120];
    }
    
    template <typename T>
    inline void qw(T x, const char aft, const bool pt) {
      if (x < 0) {x = -x, putchar('-');}
      int top=0;
      do {OPT::buf[++top] = static_cast<char>(x % 10 + '0');} while (x /= 10);
      while (top) putchar(OPT::buf[top--]);
      if (pt) putchar(aft);
    }
    
  • 相关阅读:
    swap函数的例子
    实现类似shared_ptr的引用计数
    使用new分配内存的类需要自己定义拷贝构造函数
    练习13.14 13.15 13.16
    查询单词,综合例子。
    无序容器
    关联容器操作
    关联容器概述
    文本查询程序
    shared_ptr与weak_ptr的例子
  • 原文地址:https://www.cnblogs.com/yifusuyi/p/11124036.html
Copyright © 2011-2022 走看看