如何让cin和cout更快?
我们知道,cin和cout的速度是小于scanf和printf的,因此我们需要加快读入和输出的速度.
以此我们可以添加如下语句:
{
ios::sync_with_stdio(false)
}//用于int main()之前
或者
ios::sync_with_stdio(false)
cout保留小数
保留小数代码如下:
cout<<setprecision(1)<<std::fixed<<x;
我们知道,cin和cout的速度是小于scanf和printf的,因此我们需要加快读入和输出的速度.
以此我们可以添加如下语句:
{
ios::sync_with_stdio(false)
}//用于int main()之前
或者
ios::sync_with_stdio(false)
保留小数代码如下:
cout<<setprecision(1)<<std::fixed<<x;