← 返回 meta 的题目列表Simplified Number Parser
类型:online_judge
Description
Given a string containing only a minus sign (-) and a decimal point (.), write a function to parse and calculate the number represented by this string.
Input
A string s with a maximum length of 1000, guaranteed to be valid and only contains minus signs and decimal points.
Output
A float representing the parsed numeric value.
Example
Input: "-123.45"
Output: -123.45
Input: "0.007"
Output: 0.007
Constraints
The minus sign and decimal point do not repeat.
The string contains only one minus sign and it must be at the start of the string, or no minus sign at all.
Example
Input
"-123.45"