Page 1 of 1

I/O problem

Posted: Wed Jul 30, 2003 3:24 am
by Zhao Le
For each line of input produce one line of output containing a floating point number with ten digits after the decimal point.
such as this kind of problem how should I use the I/O fuction?

In C I can use the printf("%.10f",...);

but I cannot find any function in C++.

I have tried cout.precision(10);

but this not mean that.

Hope anyone can help.

Posted: Wed Jul 30, 2003 4:17 am
by Krzysztof Duleba
Try something like

Code: Select all

cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(10); 
Zero will be printed as 0.0000000000. Is this what you want?

Thanks

Posted: Wed Jul 30, 2003 4:40 am
by Zhao Le
Thanks you did solve a big problem for me.