To flush you can use (just after printing an integer and end-of-line):
-
fflush(stdout) in C++;
-
System.out.flush() in Java;
-
stdout.flush() in Python;
-
flush(output) in Pascal;
-
See the documentation for other languages。这段话的意思就是要在c++的printf之后使用fflush(stdout)好处是
在使用多个输出函数连续进行多次输出时,有可能发现输出错误。