提升C++输入输出性能的三个方法
来源:互联网 发布:us域名注册 编辑:程序博客网 时间:2024/04/30 22:10
做题的时候,由于数据量大,很多情况下得用scanf和printf代替cin和cout用于输入输出。难道C++不行么?
百度了一下,有三条建议用于提高C++的输入输出速度:
- At the first line in main function,add :std::ios_base::sync_with_stdio(false).which cancel theSynchronization between <iostream> and <cstdio>;
- At the second line in main function,add: std::cin.tie(0).which leads to that cin ties nothing.cin ties cout at first.
- For all endl, use '\n' or"\n" instead.
例如:
<pre name="code" class="cpp">#include<iostream>#include<algorithm>#include<cstring>using namespace std;int main(){ std::ios::sync_with_stdio(false); cin.tie(0); int n,m; cin>>n>>m; cout<<n<<" "<<m<<"\n"; return 0;}
0 0
- 提升C++输入输出性能的三个方法
- 提升C++输入输出性能的三个方法
- 提升C++输入输出性能
- JPA2.1 中三个提升应用性能的新功能
- JPA2.1 中三个提升应用性能的新功能
- JAVA技术提升EJB性能的方法
- JAVA技术提升EJB性能的方法
- 提升Java性能的一些方法
- 提升Asp.net性能的一些方法
- 提升ASP.net性能的方法
- 提升PHP性能的21种方法
- Java编程中提升性能的方法
- 提升magento性能的有效方法
- 提升java性能的基本方法
- 提升Java性能的基本方法
- 关于ListView提升性能的方法
- 提升项目性能的几个简单方法
- 提升Java性能的基本方法
- Android 在Eclipse中使用Ant Build构建项目时出现的"crunch"
- Unity3D学习之(高级查询和聚合函数)
- 第16周项目1-数组的排序
- stm32时钟分析
- LeetCode刷题之三:判断两个二叉树是否相同
- 提升C++输入输出性能的三个方法
- UVA - 11059 Maximum Product
- bzoj1208: [HNOI2004]宠物收养所 SBT&&Splay
- uva 12300 Smallest Regular Polygon(计算几何)
- poj解题报告——1182
- gdb调试core文件
- Linux 0.11 malloc分析
- Cortex-M3 bit-band (位带)的学习
- 修改开机动画