众所周知,c++中 cout 优化后是比 printf 快的。 但前提是换行时不能用:
cout<<endl
而要用
cout<<'\n' 。
所以本人有一个问题, \n 和 endl 到底有啥区别,为啥用 endl 就会慢如蜗牛,用 \n 就会很快呢? 有没有知道的大佬回复一下。