#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); }