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-03Sample Output 1:
0.00123400Sample Input 2:
-1.2E+10Sample Output 2:
-12000000000
//科学计数法,科学计数法可以处理非常大和非常小的数
//这种题目主要特点比较繁琐
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <string>
using namespace std;
char str[10000];
int main(void)
{
scanf("%s", str);//输入数字分为一般数和零
int length = strlen(str);
bool isPos = str[0] == '+' ? true : false;
int i = 2;
if (i < length)
str[i] = str[i-1];
while (i < length && str[i] != 'E')
++i;
bool exPos = str[i+1] == '+' ? true : false;
int exp = 0;
for (int j = i + 2; j < length; ++j)
exp = exp * 10 + str[j] - '0';
if (!isPos)
printf("-");
if (exPos)
{
int j = 2;
while (j < i && exp >= 0)
{
printf("%c", str[j]);
++j;
--exp;
}
if (j < i)
{
printf(".");
while (j < i)
{
printf("%c", str[j]);
++j;
}
}
while (exp >= 0)
{
printf("0");
--exp;
}
printf("\n");
}
else
{
printf("0.");
while (exp > 1)
{
printf("0");
--exp;
}
int j = 2;
while (j < i)
{
printf("%c", str[j]);
++j;
}
printf("\n");
}
return 0;
}