Identifying Legal Pascal Real Constants
Time limit1sMemory limit128 MB
Classify each candidate line as a legal Pascal real constant or not, following the syntax rules for digits, decimal points, scale factors, and signs.
- Level
Medium4 of 10
- Topics
- String, Implementation, Simulation
- Solved
- No attempts yet
Problem
Pascal requires that real constants have either a decimal point, or an exponent (which starts with the letter e or E, and is officially called a scale factor), or both, in addition to the usual collection of decimal digits. If a decimal point is included, it must have at least one decimal digit on each side of it. As expected, a sign (+ or -) may precede the entire number, or the exponent, or both. Exponents may not include fractional digits. Blanks may precede or follow the real constant, but they may not be embedded within it. Note that the Pascal syntax rules for real constants make no assumptions about the range of real values, and neither does this problem.
Your task is to identify legal Pascal real constants.
Input
Each line of the input contains a candidate string that you must classify. The input terminates with a line that contains only an asterisk (*) in column one.
Output
For each input line, print the candidate with its surrounding blanks removed, followed by is legal. if it is a legal Pascal real constant, or is illegal. otherwise.