这句语句是用来取消cin的同步,什么叫同步呢?就是iostream的缓冲跟stdio的同步。若是你已经在头文件上用了using namespace std;那么就能够去掉前面的std::了。取消后就cin就不能和scanf,sscanf, getchar, fgets之类同时用了,不然就可能会致使输出和预期的不同。ios
#include <iostream> #include <cstdio> using namespace std; int main() { cout.sync_with_stdio(false); cout << "a\n"; printf("b\n"); cout << "c\n"; } 输出结果是 b a c
取消同步的目的,是为了让cin不超时,另外cout的时候尽可能少用endl,换用"\n",也是防止超时的方法。spa
固然,尽可能用scanf,printf就不用考虑这种由于缓冲的超时了。code