#include <iostream> #include <iomanip> using namespace std; int main (){ //保留3位有效数字?(四舍五入)->cout cout<<setprecision(3)<<3.004<<endl; //精确小数点3位? (四舍五入)->cout cout<<fixed<<setprecision(3)<<3.015<<endl; //精确小数点3位? (四舍五入)->printf //int %d float %fdouble %lf char %c string %s printf("%1.3f \n %1.3f",3.0012,3.0155); }