Scientific Notation
描述
Your task is to use Lex and regular expression to find out all the input lines that satisfy the definition of normalized scientific notation. Please print each line that satisfies the normalized scientific notation with a newline character.
定義
mE ^ n, m ∈ R, 1 ≦ |m| < 10, n ∈ Z
A scientific notation is made up by normalized significand(m) and Exponentiation(n).
The definition of normalized significand is m, m ∈ R, 1 ≦ |m| < 10.
The definition of Exponentiation is n, n ∈ Z.
Here are some examples
(ex) 3.14E159 ✔ (ex) 31.4E159 ❌
(ex) 3.14E+159 ✔ (ex) +3.14E+159 ✔
(ex) +3.14E159 ✔ (ex) 31.4E1.59 ❌
範例輸入:
3.14E159
3.14E+159
+3.14E159
+3.14E+159
31.4E159
31.4E1.59
31.4E+159
31.4E-159
+31.4E+159
-31.4E-159
範例輸出:
3.14E159
3.14E+159
+3.14E159
+3.14E+159
%option noyywrap sn ^[+-]?[1-9](\.[0-9]+)?[eE][+-]?[0-9]+\n %% {sn} {ECHO;printf("\n");} . \n %% int main(int argc,char *argv[]) { yylex(); return(0); } |