好长时间没有遇到这种问题了,以前虽然知道scanf比cin快,但是没想到快这么多,见图。
50万的数据。
scanf输入:
cin输入:
网上说用std::ios::sync_with_stdio(false);可以优化。优化完的速度:
还和纯scanf差好多。