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
/*
Name:
Copyright:
Author: 流照君
Date: 2019/8/22 9:58:53
Description:
*/
#include <iostream>
#include<string>
#include <algorithm>
#include <vector>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
string s;
int main(int argc, char** argv)
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
ll flag=0,flag1,flag2,sum=0,e,flag3,k=0;
cin>>s;
if(s[0]=='-')
flag=0;
else
flag=1;
for(ll i=1;i<s.length();i++)
{
if(s[i]=='E')
{
e=i;
if(s[i+1]=='-')
flag1=0;
else
flag1=1;
flag3=i+1;
}
if(i>flag3)
{
sum=sum*10+s[i]-'0';
}
}
//cout<<sum<<endl;
if(sum==0)//这个不写竟然没关系!
{
for(int i=0;i<e;i++)
cout<<s[i];
cout<<endl;
}
else
{
if(flag1==0)
{
if(flag==0)
cout<<'-';
cout<<"0.";
for(int i=1;i<sum;i++)
cout<<'0';
for(int i=1;i<e;i++)
{
if(i==2)
continue;
cout<<s[i];
}
cout<<endl;
}
else
{
if(flag==0)
cout<<'-';
for(ll i=1;i<e;i++)
{
if(i==2)
{
k=0;
continue;
}
cout<<s[i];
k++;
if(k==sum&&i!=(e-1))
cout<<'.';
}
for(ll i=1;i<=sum-(e-2-1);i++)
cout<<'0';
cout<<endl;
}
}
return 0;
}
k如果是局部变量得初始化为0,否则就设为全局变量自动初始化为0,
不初始化k会出现各种奇怪的错误
这或许就是玄学吧