PAT 1073. Scientific Notation (20)

Source: Internet
Author: User

1073. Scientific Notation (20)

Scientific notation is the the-the-by-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 have exactly one digit, there is at least one digit in the Fractiona L portion, and the number and its exponent ' s signs is always provided even when they is positive.

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

Input Specification:

Each input file contains the one test case. There is one line containing the real number A in scientific notation. The number is no further than 9999 bytes in length and the exponent ' s absolute value are no more than 9999.

Output Specification:

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

Sample Input 1:
+1.23400E-03
Sample Output 1:
0.00123400
Sample Input 2:
-1.2E+10
Sample Output 2:
-12000000000

1#include <iostream>2#include <string>3 4 using namespacestd;5 6 intMain ()7 {8     strings;9CIN >>s;Ten  One     if(s[0] =='-') Acout << s[0]; -     inti =1; -     stringnum; the      while(S[i]! ='E'&&i<s.size ()) -     { -         if(S[i]! ='.') - Num.insert (Num.end (), s[i]); +i++; -     } +i++; A     intFlag =1, radix =0; at     if(s[i++] = ='-') -Flag =-1; -      while(I <s.size ()) -     { -Radix = Radix *Ten+ S[i]-'0'; -i++; in     } -  to     intPointIndex =1+ flag*Radix; +     if(PointIndex <=0) -cout <<"0."<<string(-pointindex,'0') <<num; the     Else if(PointIndex >=num.size ()) *cout << Num <<string(Pointindex-num.size (),'0'); $     ElsePanax Notoginseng     { -          for(inti =0; I < num.size (); i++) the         { +             if(i = =PointIndex) Acout <<"."; thecout <<Num[i]; +         } -     } $}

PAT 1073. Scientific Notation (20)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.