1073 Scientific Notation (20 分)
 

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<bits/stdc++.h>
using namespace std;
typedef long long ll; int to_int(string s){
int sum=;
for(int i=;i < s.size();i++){
sum = sum*+(s[i]-'');
}
return sum;
} int main(){
string s;cin >> s;
if(s[] == '-')cout << "-";
s = s.substr(,s.size()-); int pose = ;
for(int i=;i < s.size();i++){
if(s[i] == 'E')pose=i;
}
string s1 = s.substr(,pose);
string s2 = s.substr(pose+,s.size()-pose-);
// cout << s1 << " " << s2 <<endl;
// cout << to_int(s2);
int cnt = to_int(s2); string temp="";
for(int i=;i<s1.size();i++){
if(s1[i]!='.')temp = temp+s1[i];
}
// cout << temp;
if(s[pose+] == '-'){
string head = "0.";
for(int i=;i < cnt-;i++) head = head+"";
head = head + temp;
cout << head;
}
else if(s[pose+] == '+'){
if(temp.size() > cnt){
for(int i=;i <= cnt;i++)cout << temp[i];
if(cnt != temp.size()-)cout << ".";
for(int i=cnt+;i < temp.size();i++)cout << temp[i];
}
else{
cout << temp;
for(int i=;i <= cnt-temp.size();i++)cout << "";
}
} return ;
}

_1AC

 

PAT 1073 Scientific Notation的更多相关文章

  1. PAT 1073 Scientific Notation[字符串处理][科学记数法]

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

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

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

  3. 1073 Scientific Notation (20 分)

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

  4. PAT Advanced 1073 Scientific Notation (20 分)

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

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

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

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

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

  7. 1073. Scientific Notation (20)

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

  8. PAT A1073 Scientific Notation (20 分)——字符串转数字

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

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

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

随机推荐

  1. docker单机网络类型

    docker单机网络类型概述 Docker 安装时会自动在 host 上创建三种网络  分别为 bridge    host   none .   可用 docker network ls 命令查看 ...

  2. Win10系统jdk环境变量配置方法

    http://www.w10zj.com/Win10xy/Win10yh_5620.html

  3. NGUI与特效的层级关系

    通过调整特效的 render queue 来解决特效与NGUI界面之间的层级关系问题,用以下脚本解决: using System.Collections.Generic; using UnityEng ...

  4. NOIP2012借教室

    题目描述 Description 在大学期间,经常需要租借教室.大到院系举办活动,小到学习小组自习讨论,都需要 向学校申请借教室.教室的大小功能不同,借教室人的身份不同,借教室的手续也不一样. 面对海 ...

  5. tensorflow变量

    tensorflow变量: 1.神经网络中的参数权重,偏置等可以作为张量保存到tensorflow的变量中 2.tensorflow变量必须被初始化 3.可被保存到文件中,下次使用重新加载即可 ten ...

  6. Vue系列之 => 路由的嵌套

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...

  7. VSCode 打开文件tab键空格数量异常问题

    [1]现象与原因 现象:用Notepad++打开文件,tab键占4个空格键.但是,用VSCode打开,tab键缺变成了3个空格键. 原因:因为VSCode默认启用了根据文件类型自动设置tabsize的 ...

  8. tiny6410 uboot启动参数的问题

    使用uboot来启动tiny6410,需要在启动参数中加入lcd=S70,才能在lcd上显示正确的画面

  9. openGL学习----相机

    0.参考:https://learnopengl-cn.github.io/01%20Getting%20started/09%20Camera/ 0.0其实相机就是搞清楚cameraPos,came ...

  10. Docker Kubernetes 创建管理 Deployment

    Docker Kubernetes YAML文件创建容器 通过创建Deployment来管理pods从而创建容器.它会同时创建容器.pod.以及Deployment ! 环境: 系统:Centos 7 ...