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. jar包 war包

    jar包和war包的区别: war是一个web模块,其中需要包括WEB-INF,是可以直接运行的WEB模块.而jar一般只是包括一些class文件,在声明了Main_class之后是可以用java命令 ...

  2. ecshop 广告调用的几种方式

    1,ECSHOP后台设置广告更换 前台调用 {insert name='ads' id=2 num=1} id值表达广告位置的id.num表示数量 2,在代码加函数 function getads($ ...

  3. windows不重装系统和重建MBR分区表来扩展系统盘

    step1. 下载Acronis Disk Director Suite工具,随便一搜都能下载的到. step2. 这个软件使用非常easy,网上有非常多图文教程.扩充盘使用Increase the ...

  4. 33.Jump Game(跳步游戏)

    Level:   Medium 题目描述: Given an array of non-negative integers, you are initially positioned at the f ...

  5. 理解Throughput和Latency

    Throughput,中文译作吞吐量.Latency,中文译作延迟.它们是衡量软件系统的最常见的两个指标. 吞吐量一般指相当一段时间内测量出来的系统单位时间处理的任务数或事务数(TPS).注意“相当一 ...

  6. topic模式下的收发

    生产者: import pika import sys connection = pika.BlockingConnection(pika.ConnectionParameters( host='lo ...

  7. 从“中产梦”中醒来,好好打工吧

    "中产"定义 自打"中产阶级/阶层"概念出现,总有人试图给出定义.搞不清何为"中产"却试图定义"中产阶级/阶层",注定是 ...

  8. valueOf()对象返回值

    valueOf()对象返回值 Array数组的元素被转换为字符串,这些字符串由逗号分隔,连接在一起.其操作与 Array.toString 和 Array.join 方法相同. Boolean为Boo ...

  9. 【记录】ajax 设置请求header的Content-Type 为 application/json;charset=utf8

    具体案例如下 $.ajax({ url: context.state.IpccSendIm, method: 'POST', data: JSON.stringify(val), headers:{' ...

  10. 2017ICPC沈阳赛现场赛 L-Tree (dfs)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6228 题目大意:给一棵树,需要用k种颜色给树上的节点染色,问你在最优的染色方案下,相同颜色的节点连接的 ...