PAT_A1073#Scientific Notation
Source:
Description:
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
Keys:
- 字符串处理
Code:
#include<cstdio>
#include<string>
#include<iostream>
using namespace std; int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("Test.txt", "r", stdin);
#endif // ONLINE_JUDGE string s;
cin >> s;
int pos = s.find('E');
string fra = s.substr(,pos);
int exp = atoi(s.substr(pos+).c_str());
fra.erase(,);
if(exp > )
{
int len = exp+-fra.size();
if(len>)
for(int i=; i<len; i++)
fra.insert(fra.end(),'');
else
fra.insert(fra.begin()+exp+,'.');
}
else
{
for(int i=; i>exp; i--)
fra.insert(fra.begin()+,'');
fra.insert(fra.begin()+,'.');
}
if(fra[]=='+')
fra.erase(,);
cout << fra; return ;
}
PAT_A1073#Scientific Notation的更多相关文章
- Excel scientific notation issue
This is a known issue, you can find more in internet. Excel will treat text(can display with num ...
- 1073. Scientific Notation (20)
题目如下: Scientific notation is the way that scientists easily handle very large numbers or very small ...
- PAT 1073 Scientific Notation
1073 Scientific Notation (20 分) Scientific notation is the way that scientists easily handle very ...
- PAT A1073 Scientific Notation (20 分)——字符串转数字
Scientific notation is the way that scientists easily handle very large numbers or very small number ...
- A1073. Scientific Notation
Scientific notation is the way that scientists easily handle very large numbers or very small number ...
- 1073 Scientific Notation (20 分)
1073 Scientific Notation (20 分) Scientific notation is the way that scientists easily handle very la ...
- PAT 1073 Scientific Notation[字符串处理][科学记数法]
1073 Scientific Notation(20 分) Scientific notation is the way that scientists easily handle very lar ...
- PAT 甲级 1073 Scientific Notation (20 分) (根据科学计数法写出数)
1073 Scientific Notation (20 分) Scientific notation is the way that scientists easily handle very ...
- PAT Advanced 1073 Scientific Notation (20 分)
Scientific notation is the way that scientists easily handle very large numbers or very small number ...
随机推荐
- ES6 find 和 filter 的区别
ES6 find 和 filter 的区别 : 遇到个功能是要分类就想说在前端过滤,不要从查数据库的时候过滤了.然后就想说除了filter还有啥好用的 发现有个find,测试一番之后发现 const ...
- 【五一qbxt】day4 数论知识
这些东西大部分之前都学过了啊qwq zhx大概也知道我们之前跟着他学过这些了qwq,所以: 先讲新的东西qwq:(意思就是先讲我们没有学过的东西) 进制转换 10=23+21=1010(2) =32+ ...
- BZOJ 3931 (网络流+最短路)
题面 传送门 分析 考虑网络流 注意到数据包走的是最短路,所以我们只需要考虑在最短路上的边 由于最短路可能有多条,我们先跑一遍Dijkstra,然后再\(O(m)\) 遍历每条边(u,v,w) 如果d ...
- LTP安装方法
git clone https://github.com/linux-test-project/ltp.git apt-get install automake make autotools ./co ...
- hdu5943 Kingdom of Obsession 二分图+打表找规律
题目传送门 Kingdom of Obsession Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- Q480S-I7 D1 笔记本使用 VS2015 运行性能探查器会导致电脑自动重启?
漏洞导致 https://www.freebuf.com/vuls/159642.html 使用以下两句 无法修复该问题,建议升级 win10 系统,使用 vs2017 reg add "H ...
- vue 中公共样式
html, body, h1, h2, h3, h4, h5, h6, p, textarea, input, select, ul, ol, li, fieldset, figure { margi ...
- Nexus搭建Maven私服中央仓库
一.概述 1.概要 现在的项目基本都是用Maven来管理工程,这样一来在公司内容搭建一个私服就非常有必要了,这样一来可以管理公司内部用的JAR包,也可以管理第三方的各种JAR来,以免每次都要从外网的仓 ...
- numpy知识点总结
一.数组方法 创建数组:arange()创建一维数组:array()创建一维或多维数组,其参数是类似于数组的对象,如列表等 反过来转换则可以使用numpy.ndarray.tolist()函数,如a. ...
- rabbiitmq非阻塞调用
https://blog.csdn.net/panxianzhan/article/details/50755409 https://blog.csdn.net/u013946356/article/ ...