#B2155. Check Valid C Identifier
Check Valid C Identifier
Check Valid C Identifier
Given a non-empty string with no whitespace, determine whether it is a legal C language identifier. The string is guaranteed not to be a reserved word in C.
C language identifiers must satisfy the following conditions:
- It is not a reserved word.
- It only contains letters, digits, and underscores (
_
). - It does not begin with a digit.
In mathematical terms, a valid identifier s must match the regular expression:
$$ ^[a-zA-Z_]\\w*$ $$inputFormat
The input consists of a single line containing a string s
without any whitespace characters.
outputFormat
Output 1
if the string is a valid C identifier, otherwise output 0
.
sample
valid_identifier
1