Source:

PAT A1073 Scientific Notation (20 分)

Description:

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

Keys:

  • 字符串处理

Code:

 #include<cstdio>
#include<string>
#include<iostream>
using namespace std; int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("Test.txt", "r", stdin);
#endif // ONLINE_JUDGE string s;
cin >> s;
int pos = s.find('E');
string fra = s.substr(,pos);
int exp = atoi(s.substr(pos+).c_str());
fra.erase(,);
if(exp > )
{
int len = exp+-fra.size();
if(len>)
for(int i=; i<len; i++)
fra.insert(fra.end(),'');
else
fra.insert(fra.begin()+exp+,'.');
}
else
{
for(int i=; i>exp; i--)
fra.insert(fra.begin()+,'');
fra.insert(fra.begin()+,'.');
}
if(fra[]=='+')
fra.erase(,);
cout << fra; return ;
}

PAT_A1073#Scientific Notation的更多相关文章

  1. Excel scientific notation issue

        This is a known issue, you can find more in internet. Excel will treat text(can display with num ...

  2. 1073. Scientific Notation (20)

    题目如下: Scientific notation is the way that scientists easily handle very large numbers or very small ...

  3. PAT 1073 Scientific Notation

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

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

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

  5. A1073. Scientific Notation

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

  6. 1073 Scientific Notation (20 分)

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

  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 (20 分) (根据科学计数法写出数)

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

  9. PAT Advanced 1073 Scientific Notation (20 分)

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

随机推荐

  1. 难倒你了吧!ArrayList 为啥要实现 RandomAccess 接口?

    作者:蔡先森_caiyq https://www.jianshu.com/p/3e2a9e4c9e01 在我们的开发中,List接口是最常见不过,而且我们几乎每天都在用ArrayList或者Linke ...

  2. jvm学习(5) 对象的创建与结构

    上图表明:jvm虚拟机位于操作系统的堆中,并且,程序员写好的类加载到虚拟机执行的过程是:当一个classLoder启动的时候,classLoader的生存地点在jvm中的堆,然后它会去主机硬盘上将A. ...

  3. 60-python基础-python3-集合-集合常用方法-交集、并集、差集、对称差集-intersection(&)-union(|)-difference(-)-symmetric_difference()

    交集.并集.差集-intersection(&)-union(|)-difference(-) 1-intersection(&) s1.intersection(s2),返回s1和s ...

  4. Java代码乱象!

    文章转载自公众号  阿里巴巴中间件 , 作者 陈昌毅 导读 查尔斯·狄更斯在<双城记>中写道:“这是一个最好的时代,也是一个最坏的时代.” 移动互联网的快速发展,出现了许多新机遇,很多创业 ...

  5. 20-基于 DSP TMS320C6455的6U CPCI高速信号处理板卡

    基于 DSP TMS320C6455的6U CPCI高速信号处理板卡 1. 板卡概述 基于 DSP TMS320C6455的CPCI高速信号处理板卡是新一代高速DSP处理平台,广泛用于DSP性能验证, ...

  6. go语言从例子开始之Example30.通道遍历

    在前面的例子中,我们讲过 for 和 range为基本的数据结构提供了迭代的功能.我们也可以使用这个语法来遍历从通道中取得的值 Example: package main import "f ...

  7. python 模仿 C/C++ 结构体

    import struct from ctypes import * class MyStruct(Structure): _fields_ = [ ("v1", c_char), ...

  8. [BZOJ1023][SHOI2008]cactus仙人掌图 DP

    题目链接 套路就是先考虑一般的树上做法.求直径的dp的做法大家应该都会吧. 那么设\(dp[i]\)表示\(i\)的子树中的点到\(i\)的最大距离. 在dp的过程中 \[ ans=\max\{dp[ ...

  9. Java对象流与序列化学习

    对象流与序列化 对象流有两个类 ObjectOutputStream:将java对象的基本数据类型和图形写入OutputStream ObjectInputStream:对以前使用ObjectOutp ...

  10. eclipse 启动项目 报错 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderLis(亲测)

    [原因] 重新 clean  和  install 了maven项目后就启动报错了.解决如下: 右键项目: 属性properties 删除掉引用的其他jar 选择 Deployment Assembl ...