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
 #include <iostream>
#include <string>
using namespace std;
int main()
{
string str, f1, num1, num2, f2, num3, res = "";
cin >> str;
int nDot, E, Exp = ;
f1 = str[];
nDot = str.find('.');
num1 = str[nDot - ];//第一位数字
E = str.find('E');
num2.assign(str.begin() + nDot + , str.begin() + E);//小数点后面的数字
f2 = str[E + ];
num3.assign(str.begin() + E + , str.end());//指数
for (int i = ; i < num3.length(); ++i)//计算指数
Exp = Exp * + num3[i] - '';
if (f1 == "-")
res += "-";
if (f2 == "-")
{
res += "0.";
res.insert(res.end(), Exp - , '');//中间插入0
}
else if (f2 == "+")
{
if (num2.length() <= Exp)//小数位不足,则直接末尾加0;
num2.insert(num2.end(), Exp - num2.length(), '');
else//小数位多余幂次,则小数点后移
num2.insert(num2.begin() + Exp, , '.');
}
res += num1 + num2;
cout << res << endl;
return ;
}

PAT甲级——A1073 Scientific Notation的更多相关文章

  1. PAT 甲级 1073 Scientific Notation (20 分) (根据科学计数法写出数)

    1073 Scientific Notation (20 分)   Scientific notation is the way that scientists easily handle very ...

  2. PAT甲级——1073 Scientific Notation (20分)

    Scientific notation is the way that scientists easily handle very large numbers or very small number ...

  3. PAT A1073 Scientific Notation (20 分)——字符串转数字

    Scientific notation is the way that scientists easily handle very large numbers or very small number ...

  4. A1073. Scientific Notation

    Scientific notation is the way that scientists easily handle very large numbers or very small number ...

  5. PAT Advanced 1073 Scientific Notation (20 分)

    Scientific notation is the way that scientists easily handle very large numbers or very small number ...

  6. PAT_A1073#Scientific Notation

    Source: PAT A1073 Scientific Notation (20 分) Description: Scientific notation is the way that scient ...

  7. PAT 1073 Scientific Notation[字符串处理][科学记数法]

    1073 Scientific Notation(20 分) Scientific notation is the way that scientists easily handle very lar ...

  8. PAT 1073 Scientific Notation

    1073 Scientific Notation (20 分)   Scientific notation is the way that scientists easily handle very ...

  9. PAT Basic 1024 科学计数法 (20 分) Advanced 1073 Scientific Notation (20 分)

    科学计数法是科学家用来表示很大或很小的数字的一种方便的方法,其满足正则表达式 [+-][1-9].[0-9]+E[+-][0-9]+,即数字的整数部分只有 1 位,小数部分至少有 1 位,该数字及其指 ...

随机推荐

  1. LeetCode 67. Add Binary【个位补0,不必对齐】【easy】

    Given two binary strings, return their sum (also a binary string). The input strings are both non-em ...

  2. 【POJ】3259 Wormholes

    题目链接:http://poj.org/problem?id=3259 题意:n个农场,m条双向路径,w条单向路径(虫洞).单向虫洞路径是负值.农夫想知道自己能不能看到自己(X). 题解:其实刚开始没 ...

  3. sparkStreaming的transformation和action详解

    根据Spark官方文档中的描述,在Spark Streaming应用中,一个DStream对象可以调用多种操作,主要分为以下几类 Transformations Window Operations J ...

  4. SVN Cannot merge into a working copy that has local modifications

    我尝试了 主支,分支都提交,但是依然无法合并. 最终,我在服务器上将分支删除,然后主支在拷贝过去. 一,打开服务器资源 二,删除分支 三,拷贝主支到分支 四,刷新分支,就能看到了. 然后在分支项目中, ...

  5. Benchmark of Large-scale Unconstrained Face Recognition-blufr 算法的理解

    Many efforts have been made in recent years to tackle the unconstrained face recognition challenge. ...

  6. log4j2 按日期分割,自动清理历史文件

    方式一:定义CronTriggeringPolicy <?xml version="1.0" encoding="UTF-8"?> <Conf ...

  7. 分享安装Apache、MySQL、PHP、LAMP的完整教程

    Operation timed out after 30000 milliseconds with 0 out of -1 bytes received请注意,在Linux中输入密码时,不会显示您输入 ...

  8. Windows 设置内网和外网同时使用

    想要电脑同时使用内网和外网必须具备两个网卡,一个是无线网卡一个是本地连接,无线网卡用来连接wifi也就是外网,而本地连接需要网线连接内网,外网是不需要做设置的,我们只需要设置内网即可,鼠标右击电脑右下 ...

  9. 二分查找总结及部分Lintcode题目分析 4

    二分法不只能像之前的记录,可以找到index~第二种类型是找到二分答案.有以下几个例子,都是之前二分法的扩展,不再赘述,只记录下忽略的点,以后回顾多注意~ 1. wood cut class Solu ...

  10. UVA-307-Sticks-dfs+剪枝

    George took sticks of the same length and cut them randomly until all parts became at most 50 units ...