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 <deque> using namespace std; int main()
{
string str;
cin>>str;
char sign=str[];
deque<char> deque_Integer;//整数
deque<char> deque_decimal;//小数
int i;
for(i=;str[i]!='.';i++) deque_Integer.push_back(str[i]);
for(i=i+;str[i]!='E';i++) deque_decimal.push_back(str[i]);
bool sign2=str[++i]=='+' ? :;//获取符号,1右移,2左移
int num=stoi(str.substr(i+,str.length()-i-));//左移或者右边移动的数量
if(sign2){//右移
while(num--){
if(!deque_decimal.empty()){
deque_Integer.push_back(deque_decimal.front());
deque_decimal.pop_front();
}else deque_Integer.push_back('');
}
}else{//左移
while(num--){
if(!deque_Integer.empty()){
deque_decimal.push_front(deque_Integer.back());
deque_Integer.pop_back();
}else deque_decimal.push_front('');
}
}
//输出
if(sign!='+') cout<<sign;
if(deque_Integer.size()==) cout<<"";
else for(int i=;i<deque_Integer.size();i++) cout<<deque_Integer[i];
if(deque_decimal.size()!=){
cout<<".";
for(int i=;i<deque_decimal.size();i++) cout<<deque_decimal[i];
}
system("pause");
return ;
}

PAT Advanced 1073 Scientific Notation (20 分)的更多相关文章

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

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

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

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

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

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

  4. 【PAT甲级】1073 Scientific Notation (20 分)

    题意: 输入科学计数法输出它表示的数字. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> u ...

  5. 1073. Scientific Notation (20)

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

  6. PAT (Advanced Level) 1073. Scientific Notation (20)

    简单模拟题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...

  7. PAT甲题题解-1073. Scientific Notation (20)-字符串处理

    题意:给出科学计数法的格式的数字A,要求输出普通数字表示法,所有有效位都被保留,包括末尾的0. 分两种情况,一种E+,一种E-.具体情况具体分析╮(╯_╰)╭ #include <iostrea ...

  8. PAT Advanced 1152 Google Recruitment (20 分)

    In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the p ...

  9. PAT Advanced 1042 Shuffling Machine (20 分)(知识点:利用sstream进行转换int和string)

    Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...

随机推荐

  1. SQL Server数据同步交换

    一.为了解决数据同步汇聚,数据分发,数据转换,数据维护等需求,TreeSoft将复杂的网状的同步链路变成了星型数据链路.     TreeSoft作为中间传输载体负责连接各种数据源,为各种异构数据库之 ...

  2. MongoDB 谨防索引seek的效率问题(转)

    目录 背景 初步分析 索引seeks的原因 优化思路 小结 声明:本文同步发表于 MongoDB 中文社区,传送门:http://www.mongoing.com/archives/27310 背景 ...

  3. 斑马打印机和欧姆龙CP1H串口通信打印

    欧姆龙CP1HPLC和斑马打印机通信 1. PLC 1.1PLC型号 CP1H 1.2通信方式 232通信,使用232扩展卡槽CP1W-CIF01. CP1W-CIF01是RS232选件板,通信距离最 ...

  4. 《Hadoop》大数据技术开发实战学习笔记(二)

    搭建Hadoop 2.x分布式集群 1.Hadoop集群角色分配 2.上传Hadoop并解压 在centos01中,将安装文件上传到/opt/softwares/目录,然后解压安装文件到/opt/mo ...

  5. Android Studio优化编译速度

    随着Android Studio的不断完善,其安卓开发者阵营也基本从Eclipse转移到了Android Studio,毕竟Android Studio是谷歌亲力亲为开发的官方开发软件.不过其最重要的 ...

  6. python 创建虚拟环境时报错OSError, setuptools下载失败

    错误信息如下: Using base prefix 'c:\\users\\huful\\appdata\\local\\programs\\python\\python36-32'New pytho ...

  7. Linux IO的五种模型 ongoing

    服务器端编程经常需要构造高性能的IO模型,常见的IO模型: 阻塞I/O模型  (Blocking IO) ------------(同步)(阻塞) 非阻塞I/O模型 (Non-Blocking IO) ...

  8. 网络编程[第一篇]基于tcp协议的套接字编程

    将服务端-客户端的连接比作双方打电话的过程 2019-07-24 一.客户端 主动的一方: 客户端实例化一个socket对象--> 主动像服务端发送连接请求--> (服务端接受请求后即可进 ...

  9. java中如何测试一段代码的运行时间

    一.以毫秒为单位.long startTime = System.currentTimeMillis(); //获取开始时间 doSomething(); //测试的代码段 long endTime ...

  10. 2.ASP.NET Core Docker学习-镜像容器与仓库

    Docker下载 https://www.docker.com/community-edition 社区版 (CE) 下载完后安装,运行 docker --version 可查看版本 基本命令: 下面 ...