Programming Question #: Output format for real numbers
Source: POJ (Coursera statement: The exercises completed on POJ will not count against the final results of Coursera. )
Note: Total time limit: 1000ms memory limit: 1000kB
Describe
The flow manipulation operator is used to implement: Enter a real number, the non-scientific counting method to output, after the decimal point to retain 5 valid digits, and then the scientific counter output, the decimal point retains 7 valid digits.
Note: The output formats on different systems and compilers are slightly different, but it is guaranteed that the default format settings in the program will result in the correct results on the OJ platform.
Input
A positive real number represented by a non-scientific notation, guaranteed to be stored with a double type.
Output
The first line: the non-scientific counting method to output the real number, after the decimal point retains 5 valid digits;
The second line: outputs the real number in scientific notation and retains 7 digits after the decimal point.
Sample input
12.34
Sample output
12.340001.2340000e+01
1#include <iostream>2 using namespacestd;3 intMain () {4 DoubleN;5CIN >>N;6COUT.SETF (iOS::fixed);7Cout.precision (5);8cout << N <<Endl;9COUT.UNSETF (iOS::fixed);Ten COUT.SETF (ios::scientific); OneCout.precision (7); Acout << N <<Endl; - return 0; -}
POJ C + + Programming programming jobs-file operations and templates