zoukankan      html  css  js  c++  java
  • iostream重载__int128

    Normal (Naive)写法,用 string(char* )

    std::ostream& operator <<(std::ostream&out,const  __int128 b) {
      std::string s;  __int128 t = b;int sig = 1;
      if(t < 0) sig = -1,t = -t;
      for(;t;t/=10) s += '0' + t % 10;
      if(sig == -1) s += '-';
      reverse(s.begin(), s.end());
      if(s.length() == 0) s += '0';
      out << s ;
      return out;
    }
    /********* istrream 类似读入挂 O(∩_∩)O *************/
    

    我突然有个大胆的想法系列

    std::ostream& operator <<(std::ostream&out, __int128 x) {
      if(x < 0) {out << "-"; out << -x; return out;}
      if(x == 0) {out << "0"; return out;}
      if(x > 10) out << x / 10;
      out << "0123456789"[x % 10];
      return out;
    }
    
    std::istream& operator >>(std::istream&in, __int128 &x) {
      char c;
      while(c = in.get(), c != '-' && !isdigit(c));
      if(c == '-') {x = '0' - (c = in.get()); while(isdigit(c = getchar()))x = x * 10 + '0' - c;}
      else {x = c - '0'; while(isdigit(c = in.get()))x = x * 10 - '0' + c;};
      return in;
    }
    
  • 相关阅读:
    express4.x socket
    validator
    服务管理,Dll查看
    复制程序,获取系统信息
    TCP HelloWord
    UDP HelloWord
    [置顶] 一个小马
    注册表编辑
    服务的启动与停止
    自下载运行
  • 原文地址:https://www.cnblogs.com/Forgenvueory/p/7725116.html
Copyright © 2011-2022 走看看