单点时限: 2.0 sec
内存限制: 512 MB
Extend atof
to handle scientific notation of the form 123.45e-6
where a floating-point number may be followed by e or E and an optionally signed exponent.
Write a program to enter a string and call atof
.
See also Exercise 4-2 in the textbook.
#include <stdio.h>
/***************************************************************/
/* */
/* DON'T MODIFY main function ANYWAY! */
/* */
/***************************************************************/
double atof(char s[]) {
// TODO: your function definition
}
#define MAXLINE 80 /* maximum input line length */
int main() {
char s[MAXLINE];
scanf("%s", s);
printf("%f\n", atof(s));
}
123.45e-6
0.000123