C++输入输出外挂
2017-07-27 11:10
162 查看
利用fread()函数进行优化,几乎是最好的一种优化方式了
#include <bits/stdc++.h> // #define test TEST using namespace std; const int mod=1e9+7; const int maxn=1e6+6; typedef long long ll; namespace IO { #define BUF_SIZE 100000 //fread -> read bool IOerror = 0; inline char nc() { static char buf[BUF_SIZE], *p1 = buf + BUF_SIZE, *pend = buf + BUF_SIZE; if (p1 == pend) { p1 = buf; pend = buf + fread(buf, 1, BUF_SIZE, stdin); if (pend == p1) { IOerror = 1; return -1; } } return *p1++; } inline bool blank(char ch) { return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t'; } inline bool read(int &x) { char ch; while (blank(ch = nc())); if (IOerror) return false; for (x = ch - '0'; (ch = nc()) >= '0' && ch <= '9'; x = x * 10 + ch - '0'); return true; } #undef BUF_SIZE }; int main(int argc, char const *argv[]) { #ifdef test freopen("test.txt","r",stdin); #endif int n; while(IO::read(n)){ printf("%d\n",n); } return 0; }
相关文章推荐
- C++ 输入输出外挂 整数
- 游戏外挂编程二之C/C++内联汇编代码和DLL
- C++起航篇——bool类型,输入输出,命名空间
- CCF 模拟B 无脑循环+输入输出外挂
- C/C++输入输出
- POJ 1904 King's Quest 强连通分量 +缩点+ 输入输出外挂 (非递归版trajan模板)
- C++的输入输出
- C++基本数据类型与输入输出
- C++:标准IO(输入输出)
- c++文件的输入输出
- 输入输出外挂
- C++基本的输入输出流
- C++中关于输入输出流中c_str
- C++实现11平台魔兽全图外挂
- VC中C++的输入输出I/O 流函数
- C++简单学习(Part1_lecture 6)(时间、输入输出、数据结构)
- 第十七周oj刷题——Problem F: C++习题 输入输出--保护继承
- visual_c++外挂教程(较详细)
- 【黑科技】C++输入输出优化技巧
- C++输入输出操作符重载