【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. ...
随机推荐
- ORA-01789: 查询块具有不正确的结果列数
问题描述 ORA-01789: 查询块具有不正确的结果列数 问题原因 sql语句用union时的 两个语句查询的字段不一致,好像顺序也要保持一致才行
- 执行PDB的PITR恢复失败的说明
Oracle 12.1版本中,UNDO表空间仅存在CDB级别(共享UNDO),来自于AskScuti博客园. Oracle 12.2版本开始,UNDO表空间同时可以存在每个PDB级别(本地UNDO). ...
- jmeter 登陆--查询存在否-->新建客户-->查询存在否 + 压测
1.登陆 正则表达式提取器和json提取器,都是后置处理器提取token(都可以在响应中以regexp tester 和 json path tester查看提取的对不对) beanshell 后置处 ...
- C++-POJ1017-Packets
贪心算法,思路见代码 本来想搜索,结果有O(1)的算法,我佛了 其实每一种6x6的方案可以打表预处理,然后dp or search 但是既然可以贪心何乐而不为呢? #include <set&g ...
- Android开发实战——记账本(5)
开发日志——(5) 今天打算将图标的功能实现,将打开图表的选项放在右上方,所以重写MainActivity中的onOptionsItemSelected方法.增添Chart选项 public ...
- Codeforces 1207C Gas Pipeline (dp)
题目链接:http://codeforces.com/problemset/problem/1207/C 题目大意是给一条道路修管道,相隔一个单位的管道有两个柱子支撑,管道柱子高度可以是1可以是2,道 ...
- Redis如果内存满了怎么办?
Redis占用内存大小 我们知道Redis是基于内存的key-value数据库,因为系统的内存大小有限,所以我们在使用Redis的时候可以配置Redis能使用的最大的内存大小. 1.通过配置文件配置 ...
- Android输入法挤乱布局问题
今天做布局的时候 嵌套的TbaleLayout里面有三行 但是准备输入的时候输入法自动将整个activity布局全部往上挤 导致输入框变小甚至消失 弄的很是郁闷 在网上查了之后 发现有些人是因为 ...
- php自制工具函数,常用的函数集合
字符串与爬虫相关 1,解析url /** * 模拟访问,可get可post * @param $curl * @param $postInfo post数组/字符串,不填默认没有post * @par ...
- python开发基础01-字符串操作方法汇总
字符串 Python对字符串的处理内置了很多高效的函数,非常方便功能很强大. "hello world" 字符串七种常用功能: 连接和合并 + join 移除空白 strip 分 ...