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. TCP Socket + UDP Socket

    小例子:http://soft.yesky.com/238/2035738.shtml 服务器程序: #include <iostream> #include <WinSock2.h ...

  2. 【ARM-Linux开发】TI 关于Gstreamer使用的几个参考

    http://processors.wiki.ti.com/index.php/Example_GStreamer_Pipelines#H.264_RTP_Streaming http://proce ...

  3. 按CSS查询一个元素

    按CSS查询 示例1 查询一个 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 < ...

  4. [学习笔记] Blender 模型编辑-挤出

    按TAB键进入模型编辑模式,再次按TAB键退出编辑模式. 或者在菜单按 Modeling 也会进入编辑模式. 进入编辑模式之后,会显示如下额外的工具栏: 下面分别对应点.线.面三种选择方式:选择了两个 ...

  5. lamp和xampp和lampp的区别

    lamp:我们最常说的lamp,是一种系统环境,由Linux+Apache+Mysql+PHP构成,常用来运行web服务器.要在系统上完成这个环境的安装,可以很复杂的一步一步编译和设置,也可以用已经集 ...

  6. windows下 安装gitlab及其相关图形管理工具

    windows下 安装gitlab及其相关图形管理工具   在windows下安装git中文版客户端并连接gitlab   下载git Windows客户端 git客户端下载地址:https://gi ...

  7. [转帖]8个优秀Docker容器监控工具,收藏了

    8个优秀Docker容器监控工具,收藏了 Docker是目前使用最广泛的容器之一,但它并不总是像物理硬件一样可见.而使用docker容器监控工具有助于消除这种透明度的缺失.以下介绍8种优秀Docker ...

  8. 获取Android手机日志

    方式一:使用USB连接 1.在手机上启用USB调试2.在终端输入adb devices 3.获取日志 只连接一个设备:1)清除已缓存日志:adb logcat -c2)获取日志并保存到本地:adb l ...

  9. java日志框架系列(7):logback框架Layout详解

    1.Layout layout从字面意思来看就是排版.布局咯. 1.Layout简介 功能:负责把事件转换成字符串.Layout接口的格式化方法doLayout()负责将代表任何类型的事件的转换成一个 ...

  10. java 中的容器(札记)

    创建容器向上转型为接口的时候,有时候,并不是一定可行的,因为有的实现类,在接口的基础添加了自己的方法:比如:List 接口下面的 LinkedList 自己定义了一些方法 : Arrays.asLis ...