使用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;}
新闻热点
疑难解答