← 返回 pinterest 的题目列表Implement custom round function
类型:online_judge
Implement a custom round() function from scratch. The input is a string. Supported string formats include decimal numbers, numbers with positive or negative signs, and numbers that can cause float() overflow.
Input Format
input_str: A string representing a floating-point number.
Ensure the code handles the following edge cases:
Floating-point overflow.
Negative decimals, such as '-.2'.
Integers with decimal points, such as '2.'.
Output Format
Return the result rounded to the nearest integer as a string.
Example
Input: '3.14159'
Output: '3'
Input: '-2.718'
Output: '-3'
Example
Input
3.14159