1073. Scientific Notation (20) time limit MS Memory limit 65536 KB code length limit 16000 B procedure StandardAuthor Hou, qiming
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
Submit Code
Scientific counting method.
1#include <cstdio>2#include <stack>3#include <algorithm>4#include <iostream>5#include <stack>6#include <Set>7#include <map>8 using namespacestd;9 stringTransstrings) {Ten intI=1; One while(I<s.length ()) {//Effective digits A if(s[i]=='E'){ - Break; - } thei++; - } - intIndex=++i;//exponential sign bit - + //cout<<index<<endl; - +i++;//Index Start A intexp=0; at //determine the index - while(I<s.length () &&s[i]=='0'){//Remove top 0 -i++; - } - - //cout<<i<<endl; in - while(I<s.length ()) {//exponential calculation toexp*=Ten; +exp+=s[i]-'0'; -i++; the } * $ //cout<<exp<<endl;Panax Notoginseng - stringSS; the if(s[index]=='-'){ +i=exp-1; Ass="0."; the while(i) { +i--; -ss=ss+'0'; $ } $ss=ss+s[1]; - for(i=3; s[i]!='E'; i++){ -ss=ss+S[i]; the } - }Wuyi Else{// thess=s[1]; - for(i=3; s[i]!='E'&&exp;i++,exp--){ Wuss=ss+S[i]; - } About if(s[i]=='E'){ $ while(exp) { -ss=ss+'0'; -exp--; - } A } + Else{ thess=ss+'.'; - while(s[i]!='E'){ $ss=ss+S[i]; thei++; the } the } the } - if(s[0]=='-'){ inss='-'+SS; the } the returnSS; About } the intMain () { the //freopen ("D:\\input.txt", "R", stdin); the strings; +Cin>>s; - //cout<<s<<endl; theCout<<trans (s) <<Endl;Bayi return 0; the}
pat1073. Scientific Notation (20)