PAT1073. Scientific Notation (20)
#include <iostream>
using namespace std;
string a;
int expo;
int dotPos;
int expoPos;
int i;
int main(){
cin>>a;
if(a[0]=='+'||a[0]=='-'){
if(a[0]=='-'){cout<<"-";}
a.erase(a.begin());
}
for(i=0;i<a.size();i++){
if(a[i]=='.'){
dotPos=i;
}
if(a[i]=='E'){
expoPos=i;
break;
}
}
string expoStr=a.substr(expoPos+1);
expo=stoi(expoStr);
string b=a.substr(0,expoPos);
b.erase(b.begin()+dotPos);
if(expo>0){
if((expoPos-dotPos)<=(expo+1)){
cout<<b;
int count=expo-(expoPos-dotPos)+1;
while(count--){cout<<"0";}
}else{
int i=0;
i+=expo+1;
b.insert(i,".");
cout<<b<<endl;
}
}else if(expo<0){
expo++;
cout<<"0.";
while(expo!=0){
cout<<"0";
expo++;
}
cout<<b<<endl;
}else{
cout<<a.substr(0,expoPos);
} return 0;
}
PAT1073. Scientific Notation (20)的更多相关文章
- 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 ...
- 【PAT甲级】1073 Scientific Notation (20 分)
题意: 输入科学计数法输出它表示的数字. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> u ...
- PAT 1073 Scientific Notation
1073 Scientific Notation (20 分) Scientific notation is the way that scientists easily handle very ...
随机推荐
- DB2 SQL方式查看版本
SELECT service_level, fixpack_num FROM TABLE (sysproc.env_get_inst_info()) as INSTANCEINFO
- JavaScript进阶之路 初学者的开始
一:写在前面的问题和话 一个javascript初学者的进阶之路! 背景:3年后端(ASP.NET)工作经验,javascript水平一般般,前端水平一般般.学习资料:犀牛书. 如有误导,或者错误的地 ...
- Openstack虚拟机创建流程
续上一篇Openstack安装配置 一,keystone交互认证阶段 1,发送用户名和密码给keystone认证获取token 2,带着token访问nova-api 3,nova-api使用toke ...
- xmapp开启https
在开发微信小程序的时候我们需要开启https本地测试,以下我们说明使用xmapp如何开启https访问 1. php中开启ssl 在php的配置文件中把openssl前面的注释去掉, 大概在配置文件的 ...
- win7(iis7)无法加载运行CSS文件的解决方法
在打开或关闭window功能中的Internet信息服务里的万维网服务=>常见HTTP功能=>静态内容 ,将其选上 即可了,如下图
- ios 画图总结
0 CGContextRef context = UIGraphicsGetCurrentContext(); 设置上下文1 CGContextMoveToPoint 开始画线2 CGContextA ...
- python return中的or和and语句
python return中的or和and语句 1.二元运算: 如果一个True,一个False或两个false: return True and False # 返回False return Tru ...
- 快压、360压缩、WinRAR关于打开快压通过超高压缩比压缩后的文件不兼容的问题
今天接收了同事发过来的一个压缩文件,用360压缩打开和用WinRAR打开压缩文件,傻眼了,这发的是什么鬼压缩包.压缩包的文件大小有27533KB,用360压缩工具解压查看只有121.5kb,而且完全没 ...
- Hessian矩阵与多元函数极值
Hessian矩阵与多元函数极值 海塞矩阵(Hessian Matrix),又译作海森矩阵,是一个多元函数的二阶偏导数构成的方阵.虽然它是一个具有悠久历史的数学成果.可是在机器学习和图像处理(比如SI ...
- node.js---sails项目开发(3)
1.为新建的sails数据库新建一个用户,首先连接数据库 mongo localhost:27017 (1)显示所有数据库 (2)切换数据库 show dbs use sails 新建一个用户 账 ...