【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. ...
随机推荐
- [CF1236D] Alice and the Doll - 模拟,STL
[CF1236D] Alice and the Doll Description \(N \times M\)网格,有 \(K\) 个格子里有障碍物.每次经过一个格子的时候只能直走或者右转一次.初态在 ...
- c#数据筛选和排序
一.TreeView SelectedNode 选中的节点 Level 节点的深度(从0开始) AfterSelect 节点选中后 ...
- ORA-01843: not a valid month
问题描述 ORA-01843: not a valid month oracle数据库插入出现无效的月份
- 测试linux是否能访问外网
方法1 curl -l http://www.baidu.com 方法2 wget http://www.baidu.com
- python 百万级别类实例实现节省内存
# 案例: ''' 某网络游戏中,定义了玩家类Player(id,name,status) 每当有一个玩家,就会在服务器创建一个Player实例 当在线人数过多时,将产生大量实例(百万级别),消耗内存 ...
- DSDT/SSDT
版权说明:本文章参考tonymacx86的Patching LAPTOP DSDT/SSDTs这篇文章 如果需要转载,请注明原文地址:http://blog.csdn.net/wr132/articl ...
- 管理QT的组件
1.在qt的安装目录找到'%QTROOT%\MaintenanceTool.exe'. 2.点击MaintenanceTool的设置,可以设置默认储存库.临时储存库.用户定义储存库,选择其中的临时储存 ...
- [学习笔记]用Python简易向喜欢的人表白
前几天是情人节,就用Python图像库PIL来搞点事情. 先看图: 其实这样看不出什么来,然后需要放大: 放大以后就能看到你相对女神说的话. 但是对于学计算机的我来说,更想琢磨是怎样的流程完成的这个图 ...
- Python获取最新电影的信息
这次将从电影天堂获取最新的电影的详细信息,这里电影的信息罗列的比较详细. 本来只是想获取电影的迅雷链接,然后用迅雷去下载.但看到这里的电影的信息比较完整和详细,忍不住把所有信息都爬取下来了. 下图是& ...
- httpclient发送请求的几种方式
package asi; import org.apache.http.HttpEntity; import org.apache.http.client.config.RequestConfig; ...