【PAT甲级】1073 Scientific Notation (20 分)
题意:
输入科学计数法输出它表示的数字。
AAAAAccepted code:
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
string s;
int ans2[];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>s;
int n=s.size();
if(s[]=='-')
cout<<'-';
int pos=;
int cnt2=;
int ans=s[]-'';
for(int i=pos;i<n;++i){
if(s[i]=='E'){
pos=i+;
break;
}
ans2[++cnt2]=s[i]-'';
}
int flag=;
if(s[pos]=='-')
flag=;
++pos;
int num=;
for(int i=pos;i<n;++i){
num*=;
num+=s[i]-'';
}
if(flag){
cout<<<<'.';
for(int i=;i<num;++i)
cout<<;
cout<<ans;
for(int i=;i<=cnt2;++i)
cout<<ans2[i];
}
else{
int num2=;
cout<<ans;
int tamp=;
for(tamp=;tamp<=cnt2&&num2<num;++tamp,++num2)
cout<<ans2[tamp];
if(tamp>cnt2)
for(int i=;i<=num-num2;++i)
cout<<;
else{
cout<<'.';
for(int i=tamp;i<=cnt2;++i)
cout<<ans2[i];
}
}
return ;
}
【PAT甲级】1073 Scientific Notation (20 分)的更多相关文章
- PAT 甲级 1073 Scientific Notation (20 分) (根据科学计数法写出数)
1073 Scientific Notation (20 分) Scientific notation is the way that scientists easily handle very ...
- PAT甲级——1073 Scientific Notation (20分)
Scientific notation is the way that scientists easily handle very large numbers or very small number ...
- 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 甲级 1035 Password (20 分)
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...
- 1073. Scientific Notation (20)
题目如下: Scientific notation is the way that scientists easily handle very large numbers or very small ...
- PAT 甲级 1050 String Subtraction (20 分) (简单送分,getline(cin,s)的使用)
1050 String Subtraction (20 分) Given two strings S1 and S2, S=S1−S2 is defined to be t ...
- PAT 甲级 1046 Shortest Distance (20 分)(前缀和,想了一会儿)
1046 Shortest Distance (20 分) The task is really simple: given N exits on a highway which forms a ...
- PAT 甲级 1042 Shuffling Machine (20 分)(简单题)
1042 Shuffling Machine (20 分) Shuffling is a procedure used to randomize a deck of playing cards. ...
随机推荐
- python 3.8 下安装 tensorflow 1.14
pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.14.0-py3-none-a ...
- P4562 [JXOJ2018]游戏
题目描述 她长大以后创业了,开了一个公司. 但是管理公司是一个很累人的活,员工们经常背着可怜偷懒,可怜需要时不时对办公室进行检查. 可怜公司有 n 个办公室,办公室编号是 l 到 l+n−1 ,可怜会 ...
- HTMLinput标签
<input> 标签用于搜集用户信息. 常用的属性: type指定输入项的类型 name定义 input 元素的名称. id给输入项取一个名字,方便后期找到和操作 type指定输入项的类型 ...
- [IOI2002] 任务安排
题目链接 题意 一些不能改变顺序的任务被分成若干批,每批包含相邻的若干任务.第 $i$ 个任务单独完成所需的时间是 $T_i$.在每批任务开始前,机器需要启动时间 $S$,而完成这批任务所需的时间是各 ...
- break continue goto
break:跳出本层循环:continue:结束本次循环,并不跳出循环:goto:转移到指定位置,无条件转移:
- 将java字节自动转为"B", "KB", "MB", "GB", "TB"等
//字节转换 public static String readableFileSize(long size) { if (size <= 0) return "0"; fi ...
- ubuntu---yolo报错darknet: ./src/cuda.c:36: check_error: Assertion `0' failed.
装好darknet后,直接测试的时候,报错: darknet: ./src/cuda.c:36: check_error: Assertion `0' failed.解决办法是打开yolov3.cfg ...
- P1908 逆序对(归并排序)
https://www.luogu.com.cn/problem/P1908 归并排序是用来求逆序对的 归并排序的思想就是分治 #include <bits/stdc++.h> using ...
- centos7 sshpass 用法详解
可以参考文章:https://www.cnblogs.com/kaishirenshi/p/7921308.html 安装方式直接通过yum 安装 yum -y install sshpass 常用的 ...
- git merge 将多个commit合并为一条之--squash 选项
转自: https://blog.csdn.net/themagickeyjianan/article/details/80333645 改进版本:合并多个提交为一条(git merge --squa ...