← 返回 meta 的题目列表Validate String as Signed Integer or Decimal Number
类型:online_judge
meta
Determine if a String is a Valid Integer
Given a string s, determine if it is a valid integer. A valid integer has the following properties:
Contains only numbers, without other characters such as punctuation or letters.
Can have a sign at the beginning, and it should be followed by numbers.
May include one decimal point but should not have multiple decimal points.
If the string is empty or contains only spaces, it is not a valid integer.
Input:
s: A string representing the integer to be validated.
Output:
A boolean value, True if s is a valid integer, False otherwise.
Examples:
Input: "123" Output: True
Input: "1.23" Output: True
Input: "abc" Output: False
Input: "1.1.1.1" Output: False
Example
Input
123