# 甲级1073. Scientific Notation (20)

100 ms

65536 kB

16000 B

Standard

HOU, Qiming

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 file 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

# 乙级1024. 科学计数法 (20)

100 ms

65536 kB

8000 B

Standard

HOU, Qiming

+1.23400E-03


0.00123400


-1.2E+10


-12000000000

#### 算法设计：

1. i为负，这种情况一定会输出“0.000XXX”的形式，其中小数点后连续的0的个数为i-1，而后面XXX部分即为s1整个字符串
2. i为正，分两种情况：如果i>=s1.size()-1，先输出s1整个字符串，然后输出i+1-s1.size()个0即可；否则输出s1整个字符串，并在输出s1的第i个字符之后输出一个小数点即可。

#### c++代码：

#include<bits/stdc++.h>
using namespace std;
int main(){
string s,s1="";
cin>>s;//读取输入的科学计数法形式的字符串
if(s[0]=='-')//如果是负数先输出-号
cout<<"-";
int i=1;
while(s[i]!='E'){//将小数部分删去小数点存储到s1字符串中
if(s[i]!='.')
s1+=s[i];
++i;
}
i=stoi(s.substr(++i));//将指数部分存储为一个整型变量
if(i<0){//i为负,输出“0.000XXX”的形式，其中小数点后连续的0的个数为i-1，而后面XXX部分即为s1整个字符串
cout<<"0.";
i=abs(i)-1;
for(int j=0;j<i;++j)
cout<<"0";
cout<<s1;
}else//i为正，分两种情况
if(i>=s1.size()-1){//如果i>=s1.size()-1，先输出s1整个字符串，然后输出i+1-s1.size()个0
cout<<s1;
for(int j=0;j<i+1-s1.size();++j)
cout<<"0";
}else//否则输出s1整个字符串，并在输出s1的第i个字符之后输出一个小数点
for(int j=0;j<s1.size();++j){
cout<<s1[j];
if(j==i)
cout<<".";
}
return 0;
}


• 擅长领域：
• 算法