zoukankan      html  css  js  c++  java
  • 玄学快读

    不保证正确性

    class IO {
    	private:
    		// 缓冲大小 
    		static const int BUF = 128 * 1024;
    		// 输入输出流 
    		FILE *in, *out;
    		char rbuf[BUF], wbuf[BUF], *rs, *rt;
    		int pos;
    		// EOF 
    		bool eof;
    	public:
    		// fread 和 fwrite 
    		bool load() { return (rt = (rs = rbuf) + fread(rbuf, 1, BUF, in)) == rs;}
    		void flush() { fwrite(wbuf, 1, pos, out); pos = 0;}
    		
    		// 构造和析构 
    		IO() { in = stdin, out = stdout, rs = rt = rbuf, pos = 0, eof = 0;}
    		~IO() { flush();}
    		
    		// 文件 
    		void open_r(const void* ch) { in = fopen((char*)ch, "r");}
    		void open_w(const void* ch) { out = fopen((char*)ch, "w");}
    		void open_r(FILE* p) { in = p;}
    		void open_w(FILE* p) { out = p;}
    		IO(const void* ch) { in = fopen((char*)ch, "r"), out = stdout, rs = rt = rbuf, pos = 0, eof = 0;}
    		IO(FILE* p) { in = p, out = stdout, rs = rt = rbuf, pos = 0, eof = 0;}
    		bool end() { return eof;}
    		
    		// 基础操作 
    		inline void pc(const char c) { if(pos >= BUF) flush(); wbuf[pos ++] = c;}
    		inline char gc() { if(rs == rt) eof = load(); return eof ? EOF : *rs ++;}
    		
    		// 读入 
    		template<typename T>
    		inline IO& operator >> (T &x) {
    			register char c, f = 1;
    			while(c = gc(), c < '0' || c > '9') if(c == '-') f = ! f;
    			x = c ^ 48;
    			while(c = gc(), c >= '0' && c <= '9' && !eof) x = (x << 3) + (x << 1) + (c ^ 48);
    			return (x = f ? x : -x), *this;
    		}
    		inline IO& operator >> (char &c) { return c = gc(), *this;}
    		inline IO& operator >> (char* c) {
    			while(*c = gc(), *c == '
    ' || *c == '
    ' || *c == ' ' || *c == '	');
    			while(*++ c = gc(), *c != '
    ' && *c != '
    ' && *c != ' ' && *c != '	' && ! eof);
    			return (*c = ''), *this;
    		}
    		inline IO& getline(char* c)
    		{ while(*c = gc(), *c != '
    ' && *c != '
    ' && ! eof) ++ c; *c = ''; return *this;}
    		inline IO& operator >> (string &s) {
    			register char c;
    			while(c = gc(), c == '
    ' || c == '
    ' || c == ' ' || c == '	');
    			s = c;
    			while(c = gc(), c != '
    ' && c != '
    ' && c != ' ' && c != '	') s += c;
    			return *this;
    		}
    		inline IO& operator >> (long double &x) {
    			register char c, op = 1; long double e = 1;
    			while(c = gc(), ! isdigit(c)) if(c == '-') op = ! op;
    			x = c ^ 48;
    			while(c = gc(), isdigit(c)) x = (x * 10) + (c ^ 48);
    			if(c == '.') while(e /= 10, c = gc(), isdigit(c)) x += (c ^ 48) * e;
    			return (x = op ? x : -x), *this;
    		}
    		inline IO& operator >> (double &x) {
    			long double y; *this >> y; return x = y, *this;
    		}
    		
    		// 输出
    		template<typename T>
    		inline IO& operator << (T x) {
    			if(x < 0) pc('-'), x = -x;
    			register T y = 10;
    			while(y <= x) y = (y << 3) + (y << 1);
    			while(y /= 10) pc((x / y) ^ 48), x %= y;
    			return *this;
    		}
    		inline IO& operator << (const char c) { return pc(c), *this;}
    		inline IO& operator << (const char* c) { while(*c) pc(*c ++); return *this;}
    		//inline IO& operator << (char c) { return pc(c), *this;}
    		inline IO& operator << (char* c) { while(*c) pc(*c ++); return *this;}
    		inline IO& putline(char* c) { while(*c) pc(*c ++); return pc('
    '), *this;}
    		inline IO& operator << (string s) { return *this << s.c_str();}
    		template<typename T>
    		inline void print(T x, short y) {
    			T t; *this << (int)(t = floor(x));
    			if(! y) return;
    			pc('.');
    			while(y) { x -= t, x *= 10; *this << (int)floor(x); y --;}
    		}
    };
    
    akakw1
  • 相关阅读:
    如何下载Bilibili视频
    pyqt5 主界面打开新主界面、打开Dialog、打开提示框的实现模板
    【爬坑】python3+pyqt5+pyinstaller 打包成exe的各种问题
    【PyQt5-Qt Designer】QComboBox(下拉列表框) 使用模板
    【PyQt5-Qt Designer】读取txt文件在打印
    pyqt5核心-信号与槽(第二弹)
    使用QT设计师-信号和槽signal-slot(第一弹)
    【python基础】python程序打包成.exe运行时会弹出黑框
    【pyqt5】QdateTimeEdit(日期时间)
    pyqt5-对文本样式进行操作
  • 原文地址:https://www.cnblogs.com/akakw1/p/10255357.html
Copyright © 2011-2022 走看看