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. Hadoop概念学习系列之Hadoop、Spark学习路线

    1 Java基础: 视频方面:          推荐<毕向东JAVA基础视频教程>.学习hadoop不需要过度的深入,java学习到javase,在Java虚拟机的内存管理.以及多线程. ...

  2. ipad 没有数据线如何上传文件到局域网windows PC 的解决方案

    是的,ios 的封闭性,真麻烦,不想用数据线,还不想用iTunes ,那你找对了. 方案一: (好像只能上传文件,不能下载,能在线查看媒体.) 我的想法是在Windows建立一个http file s ...

  3. 【OpenGL学习】 四种绘制直线的算法

    我是用MFC框架进行测试的,由于本人也没有专门系统学习MFC框架,代码若有不足之处,请指出. 一,先来一个最简单的DDA算法 DDA算法全称为数值微分法,基于微分方程来绘制直线. ①推导微分方程如下: ...

  4. python return逻辑判断表达式(21)

    一.return逻辑判断表达式 and and:遇假则假,所以前面为假就不执行和判断后面直接返回假:前面为真则继续判断执行后面直到表达式结束或者出现假为止; # !usr/bin/env python ...

  5. ubuntu的sudo免密

    ubuntu的sudo免密与centos大同小异,都是在/etc/sudoers中添加用户信息,添加的内容也一样,只是位置不一样. centos的位置如下: 而ubuntu的位置如下: 除此之外,两行 ...

  6. c# 中对于每次修改的程序 都必须重新手动生成 才能编译的问题

    问题描述:原来用VS2017,升级了VS2019,发现修改了Winform界面,F5运行竟然还是原来的界面 问题解决: 需要修改两个地方 工具>> 选项>> 项目和解决方案&g ...

  7. TypeScript 类型推导及类型兼容性

    类型推导就是在没有明确指出类型的地方,TypeScript编译器会自己去推测出当前变量的类型. 例如下面的例子: let a = 1; 我们并没有明确指明a的类型,所以编译器通过结果反向推断变量a的类 ...

  8. Druid基本配置

    最近公司要用Druid 所以看了下基本配置及配置过程中出现的问题 Druid是什么? Druid是阿里巴巴开源平台上一个数据库连接池实现,它结合了C3P0.DBCP.PROXOOL等DB池的优点,同时 ...

  9. C++之父给 C 程序员的建议

    1. 在 C++中几乎不需要用宏, 用 const 或 enum 定义显式的常量, 用 inline 避免函数调用的额外开销,用模板去刻画一族函数或类型,用 namespace 去避免命名冲突. 2. ...

  10. DMA存储器到外设代码讲解

    实验目的: bsp_dma_mtp.h #ifndef __BSP_DMA_MTP_H #define __BSP_DMA_MTP_H #include "stm32f10x.h" ...