函数原型
static bool
sync_with_stdio(bool __sync = true);
//in <ios_base.h>
函数缺点
建立同步输入输出缓存,耗费大量时间(数据量超过1000000时便会超时)。
如何取消同步
std::ios::sync_with_stdio(false);
加入本代码之前运行时间:921ms.
加入之后运行时间:187ms.
仅仅多了一个ios::sync_with_stdio(false);,运行时间就少了好几倍。
取消后的注意事项
给一段代码:
#include<iostream>
#include<cstring>
using namespace std;
int main(){
string s;
cin>>s;
return 0;