一种方法
cout.precision(n); //n为有效数字个数,即输出精度
cout.flags(cout.fixed) //定点,即小数点后有n个有效数字
可以用cout<<fixed代替
cout.unsetf(cout.fixed) //取消定点法,即变成输出n个有效数字
一种方法
cout.precision(n); //n为有效数字个数,即输出精度
cout.flags(cout.fixed) //定点,即小数点后有n个有效数字
可以用cout<<fixed代替
cout.unsetf(cout.fixed) //取消定点法,即变成输出n个有效数字