C++关闭同步流 ios::sync_with_stdio(false);

C++关闭同步流 ios::sync_with_stdio(false);

2018年07月24日 21:29:21  阅读数:359

转载于 happyaaakkk

https://blog.csdn.net/aaakkk_1996/article/details/81192816

  1. cin和cout比scanf和printf慢很多,因为先把要输出的东西存入缓冲区,再输出,导致效率降低。
  2. scanf和printf在cstdio中
  3. std::ios::sync_with_stdio(false);关闭输入输出缓存,可以加快cin和cout

还有就是,用\n而不是 endl,也可以提高速度

猜你喜欢

转载自blog.csdn.net/Cherishlife_/article/details/85338068