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. Codis-dashboard的配置和启停

    Codis-dashboard是集群的管理工具 生成配置文件,即将现有的配置文件输出到指定目录位置: ./codis-dashboard --default-config | tee conf/das ...

  2. [CF369E]Valera and Queries_离线_树状数组

    Valera and Queries 题目链接:codeforces.com/problemset/problem/369/E 数据范围:略. 题解: 这种题,就单独考虑一次询问即可. 我们发现,包括 ...

  3. 把cgrep mgrep集成到bashrc

    https://android.googlesource.com/platform/build/+/android-4.4.3_r1/envsetup.sh 在~/.bashrc里面增加: #Andr ...

  4. Scrapy各部分运行机制?Xpath为None?多层Response如何编写?搞定Scrapy的坑

    前言 Scrapy那么多模块都是怎么结合的啊?明明在chrome上的xpath helper插件写好了xpath,为什么到程序就读取的是None?Scrapy可以直接写多层response么?难道必须 ...

  5. root用户和sudo使用root权限的区别(转)

    百度百科:https://baike.baidu.com/item/sudo/7337623?fr=aladdin sudo指令 功能: 以root的身分执行命令 语法: sudo 其他指令 用户: ...

  6. MySql数据库 优化

    MySQL数据库优化方案 Mysql的优化,大体可以分为三部分:索引的优化,sql慢查询的优化,表的优化. 开启慢查询日志,可以让MySQL记录下查询超过指定时间的语句,通过定位分析性能的瓶颈,才能更 ...

  7. 怎样理解数组的空元素empty与undefined的区别

    数组的空元素empty表示空位, 它不是一种数据类型, 而是由于人为修改arr.length 或者写入时多写了逗号造成的. var arr = [1,2,3,4,,,5]; arr.length; a ...

  8. win10 右键新建卡顿

    前段时间不知道自己搞啥了,右键变得很慢,找了一些常规的解决方案,什么清除注册表等等的,对我来说,没好用. 然后将就继续使用,然后觉得是office的问题,卸载,重装2010的,发现还是一样卡... 继 ...

  9. (九) spring 使用自定义限定符注解

    案例一 定义接口  CD.java package interfacepackage; public interface CD { void play(); } 定义接口 player .java p ...

  10. WebAPI 笔记

    一.基本配置 1. 全局配置 Global.asax public class WebApiApplication : System.Web.HttpApplication { protected v ...