使用ios::sync_with_stdio(false);語句
cin,cout之所以效率低,是因為先把要輸出的東西存入緩沖區,再輸出,導致效率降低,而這段語句可以來打消iostream的輸入輸出緩存,可以節省許多時間,使效率與scanf與PRintf相差無幾,但是還是比scanf與printf略慢,但已經不影響題目通過了。
#include<iostream>using namespace std;int main(){ ios::sync_with_stdio(false); string a; int x,y; cin>>a>>x>>y; cout<<a<<endl<<x<<endl<<y<<endl; return 0;}
新聞熱點
疑難解答