1073 Scientific Notation
题意:
给出科学计数法的形式,转化成常规的表示,要求保留所有的有效位数
思路:纯粹的字符串处理问题,注意边界条件即可。如+1.23E+02这种,转化后是123,既不需要补0,也不需要添加小数点。
代码:
#include <iostream>
#include <string>
using namespace std;
string change(string str)
{
string ans,sign;
]=='-') sign="-";
str.erase(str.begin());
int pos=str.find("E");
,str.size()--pos);
str=str.substr(,pos);
int exp=stoi(strExp);
pos=str.find(".");
str.erase(pos,);
){//前面添0
ans=,')+str;
}else{//后面补0
;//小数点后面的位数
');
else if(len>exp) {
ans=str;
ans.insert(exp+,".");
}else{
ans=str;
}
}
return sign+ans;
}
int main()
{
string str;
cin>>str;
cout<<change(str);
;
}
1073 Scientific Notation的更多相关文章
- PAT 1073 Scientific Notation
1073 Scientific Notation (20 分) Scientific notation is the way that scientists easily handle very ...
- 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 ...
- 1073. Scientific Notation (20)
题目如下: Scientific notation is the way that scientists easily handle very large numbers or very small ...
- PAT Advanced 1073 Scientific Notation (20 分)
Scientific notation is the way that scientists easily handle very large numbers or very small number ...
- PAT Basic 1024 科学计数法 (20 分) Advanced 1073 Scientific Notation (20 分)
科学计数法是科学家用来表示很大或很小的数字的一种方便的方法,其满足正则表达式 [+-][1-9].[0-9]+E[+-][0-9]+,即数字的整数部分只有 1 位,小数部分至少有 1 位,该数字及其指 ...
- PAT甲级——1073 Scientific Notation (20分)
Scientific notation is the way that scientists easily handle very large numbers or very small number ...
- PAT (Advanced Level) 1073. Scientific Notation (20)
简单模拟题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...
- PAT甲题题解-1073. Scientific Notation (20)-字符串处理
题意:给出科学计数法的格式的数字A,要求输出普通数字表示法,所有有效位都被保留,包括末尾的0. 分两种情况,一种E+,一种E-.具体情况具体分析╮(╯_╰)╭ #include <iostrea ...
随机推荐
- Jni_Linux_01_转
1.Linux下JNI的使用(http://www.cnblogs.com/bastard/archive/2012/05/17/2506877.html) Linux下 JNI的使用 学习Andro ...
- 用JS判断IE版本的代码
方法一: 复制代码代码如下: <script language="javascript"> function getIE() { if(navigator.appNam ...
- Mongodb笔记(三)user && aggregate && mapReduce
版本:mongodb3.4. User: mongodb使用验证登录:默认不开启,mongod中使用--auth开启: mongod -port=3000 --auth : 基本方法: db.cr ...
- Spring 自定义标签配置
前景:经常使用一些依赖于Spring的组件时,发现可以通过自定义配置Spring的标签来实现插件的注入,例如数据库源的配置,Mybatis的配置等.那么这些Spring标签是如何自定义配置的?学习Sp ...
- 第三方库PIL简单使用
PIL为第三方库,需要简单安装,最容易的安装方法 pip install PIL 详细内容见http://effbot.org/imagingbook/ 下面展示一个简单用例:(字母验证码简单实现) ...
- "下载"文件夹的desktop.ini
下载 [.ShellClassInfo] LocalizedResourceName=@%SystemRoot%\system32\shell32.dll,-21798 IconResource=%S ...
- 六 web爬虫讲解2—urllib库爬虫—基础使用—超时设置—自动模拟http请求
利用python系统自带的urllib库写简单爬虫 urlopen()获取一个URL的html源码read()读出html源码内容decode("utf-8")将字节转化成字符串 ...
- day26 CRM search && 增删改查
代码:https://github.com/liyongsan/git_class/tree/master/day26/LuffyCRM ORM查询之Q学习 http://www.cnblogs.co ...
- 【scala】定义变量和函数
1.定义变量 Scala的变量分为两种,val和var. val跟java的final变量类似,一旦初始化就不能被重新赋值. var类似于java的非final变量,在整个生命周期内var可以被重新赋 ...
- form表单的提交地址一定要是完整的绝对地址
<form action="<%=path%>/servlet/DologinServlet" =<form action="<%=requ ...