-->
当前位置:首页 > 题库

PROGRAMMING:Realization of atof function

Luz5年前 (2021-05-10)题库437
Enter a set of numeric strings and convert them to double floating-point numbers.
Requirements: cannot use the system function atof, you need to define and implement the function yourself.
###Input format:
Enter multiple numeric strings separated by line breaks. Strings may include spaces, positive and negative symbols, decimal points, and other non numeric characters.
When converting the input string, the first step is to skip the space character at the beginning of the line, and the conversion will not start until the number, decimal point or positive and negative sign is encountered. When other non numeric characters are encountered or the string ends, the conversion will be ended, and the result will be returned.
When the character 'Q' is entered, the program ends.
###Output format:
Double floating-point number, showing six decimal places.
When it is a positive number, the first digit of the floating-point number does not show '+'.
When it is negative, the first digit of the floating-point number shows' - '
###Input example:
Here is a set of inputs. For example:
```in
six point three four eight
-2.98
.525
q
```
###Output example:
The corresponding output is given here. For example:
```out
six point three four eight zero zero zero
-2.980000
zero point five two five zero zero zero
```







answer:If there is no answer, please comment