正文
增加 3 行删除 24 行
12345643 行未改动505152535455565758596061626364656667686970717273747576777879808182838485868710 行未改动你以前编程课时老师是不是跟你讲 printf 比 cout 快,然后你就呆呆地信了~那个人就是我~。但是,有一天我突发奇想,printf 真的比 cout 快吗?想要搞清这一点,我们还是要做实验。开始实验:### 第一场```cppios::sync_with_stdio(false);43 行未改动```29.97 seconds依旧 cout 胜显然输出字符串 cout 完胜 printf还是有人要力挺 printf:"那输出变量的话是不是还是printf快"### 第三场:```cpp#include<bits/stdc++.h>using namespace std;int main(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);for(int i=0;i<1e5;i++) cout<<i<<"\n";}```1.86 seconds```cpp#include<bits/stdc++.h>using namespace std;int main(){for(int i=0;i<1e5;i++) printf("%d\n",i);}```16.07 secondscout 胜又有人要说了……停停停,我懂,打开输入输出流。### 第四场```cpp#include<bits/stdc++.h>using namespace std;int main(){for(int i=0;i<1e5;i++) cout<<i<<"\n";}```8.103 seconds```cpp#include<bits/stdc++.h>using namespace std;10 行未改动12345643 行未改动505152535455565758596061626364656610 行未改动你以前编程课时老师是不是跟你讲 printf 比 cout 快,然后你就呆呆地信了~那个人就是我~。但是,有一天我突发奇想,printf 真的比 cout 快吗?实(石)践(剑)是检验真理的唯一标准。开始实验:### 第一场```cppios::sync_with_stdio(false);43 行未改动```29.97 seconds依旧 cout 胜显然输出字符串 cout 完胜 printf"那输出变量的话是不是还是printf快?"### 第三场```cpp#include<bits/stdc++.h>using namespace std;int main(){for(int i=0;i<1e5;i++) cout<<i<<"\n";}```8.103 seconds```cpp#include<bits/stdc++.h>using namespace std;10 行未改动