setf
precision
#include <iostream> using namespace std; int main () { double f = 3.14159; cout.setf(ios::fixed,ios::floatfield); cout.precision(3); cout << f << endl; return 0; }
这打印3.142