A1073 Scientific Notation (20 分) / B1024 科學計數法 (20 分)(**)

Scientific notation is the way that scientists easily handle very large numbers or very small numbers. The notation matches the regular expression [+-][1-9].[0-9]+E[+-][0-9]+ which means that the integer portion has exactly one digit, there is at least one digit in the fractional portion, and the number and its exponent's signs are always provided even when they are positive.

Now given a real number A in scientific notation, you are supposed to print A in the conventional notation while keeping all the significant figures.

Input Specification:

Each input contains one test case. For each case, there is one line containing the real number A in scientific notation. The number is no more than 9999 bytes in length and the exponent's absolute value is no more than 9999.

Output Specification:

For each test case, print in one line the input number A in the conventional notation, with all the significant figures kept, including trailing zeros.

Sample Input 1:

+1.23400E-03

Sample Output 1:

0.00123400

Sample Input 2:

-1.2E+10

Sample Output 2:

-12000000000

 這道題不是有的得分點沒過,而是根本沒有一個完整的、正確的思路,情況分支有些複雜,但是其實認真審題+仔細分析+類比推理,能夠總結出讀取到的數字(程序中用字符串的形式處理)中小數點和正負號是有固定位置的,需要補的0也是有計算公式的。以後再遇到這種邏輯較複雜的題目,先拿筆寫幾個實例,總結規律,解題思路就清晰明瞭了。

 還有一個注意點:

用gets會編譯不通過,不管頭文件加<string.h>還是<cstring>,於是改成了scanf,就可以編譯運行。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章