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. go 上下文context

    go控制并发有两种经典的方式,一种是WaitGroup,另外一种就是Context WaitGroup这种方式是控制多个goroutine同时完成 func main() { var wg sync. ...

  2. each of which 用法

    each of which 在以下為 同位語,非關代. 1. An urn contains two balls, each of which is known to be either white ...

  3. SLA服务可用性4个9是什么意思?怎么达到?

    SLA:服务等级协议(简称:SLA,全称:service level agreement).是在一定开销下为保障服务的性能和可用性,服务提供商与用户间定义的一种双方认可的协定.通常这个开销是驱动提供服 ...

  4. StackExchange.Redis 使用LuaScript脚本模糊查询hash

    原文:StackExchange.Redis 使用LuaScript脚本模糊查询hash 获取redis连接 public class RedisHelper { private static rea ...

  5. 关于iframe跨页面设置高度

    注意:这两种方式不支持跨域使用 1.jQuery简单实现iframe的高度根据页面内容自适应的方法(加载后展示使用) 方式1: //注意:下面的代码是放在和iframe同一个页面中调用 $(" ...

  6. 源码分析--ConcurrentHashMap与HashTable(JDK1.8)

    ConcurrentHashMap和Hashtable都是线程安全的K-V型容器.本篇从源码入手,简要说明它们两者的实现原理和区别. 与HashMap类似,ConcurrentHashMap底层也是以 ...

  7. JavaScript面向对象编程(1)-- 基础

    自从有了Ajax这个概念,JavaScript作为Ajax的利器,其作用一路飙升.JavaScript最基本的使用,以及语法.浏览器对象等等东东在这里就不累赘了.把主要篇幅放在如何实现JavaScri ...

  8. python 子类继承父类__init__(转载)

    转载: http://www.jb51.net/article/100195.htm 前言 使用Python写过面向对象的代码的同学,可能对 __init__ 方法已经非常熟悉了,__init__方法 ...

  9. 175-基于TI DSP TMS320C6455、Xilinx V5 FPGA XC5VSX95T的高速数据处理核心板

    基于TI DSP TMS320C6455.Xilinx V5 FPGA XC5VSX95T的高速数据处理核心板 一.板卡概述 该DSP+FPGA高速信号采集处理板由我公司自主研发,包含一片TI DSP ...

  10. myeclipse2014删除antlr-2.7.2.jar--解决struts和hibernate包冲突

    方式一: 要求眼疾手快,在workspace下的D:\myeclipse2014workspace\.metadata\.me_tcat7\webapps\工程名\WEB-INF\lib中将antlr ...