题意:

输入科学计数法输出它表示的数字。

AAAAAccepted code:

  1. #define HAVE_STRUCT_TIMESPEC
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. string s;
  5. int ans2[];
  6. int main(){
  7. ios::sync_with_stdio(false);
  8. cin.tie(NULL);
  9. cout.tie(NULL);
  10. cin>>s;
  11. int n=s.size();
  12. if(s[]=='-')
  13. cout<<'-';
  14. int pos=;
  15. int cnt2=;
  16. int ans=s[]-'';
  17. for(int i=pos;i<n;++i){
  18. if(s[i]=='E'){
  19. pos=i+;
  20. break;
  21. }
  22. ans2[++cnt2]=s[i]-'';
  23. }
  24. int flag=;
  25. if(s[pos]=='-')
  26. flag=;
  27. ++pos;
  28. int num=;
  29. for(int i=pos;i<n;++i){
  30. num*=;
  31. num+=s[i]-'';
  32. }
  33. if(flag){
  34. cout<<<<'.';
  35. for(int i=;i<num;++i)
  36. cout<<;
  37. cout<<ans;
  38. for(int i=;i<=cnt2;++i)
  39. cout<<ans2[i];
  40. }
  41. else{
  42. int num2=;
  43. cout<<ans;
  44. int tamp=;
  45. for(tamp=;tamp<=cnt2&&num2<num;++tamp,++num2)
  46. cout<<ans2[tamp];
  47. if(tamp>cnt2)
  48. for(int i=;i<=num-num2;++i)
  49. cout<<;
  50. else{
  51. cout<<'.';
  52. for(int i=tamp;i<=cnt2;++i)
  53. cout<<ans2[i];
  54. }
  55. }
  56. return ;
  57. }

【PAT甲级】1073 Scientific Notation (20 分)的更多相关文章

  1. PAT 甲级 1073 Scientific Notation (20 分) (根据科学计数法写出数)

    1073 Scientific Notation (20 分)   Scientific notation is the way that scientists easily handle very ...

  2. PAT甲级——1073 Scientific Notation (20分)

    Scientific notation is the way that scientists easily handle very large numbers or very small number ...

  3. PAT Advanced 1073 Scientific Notation (20 分)

    Scientific notation is the way that scientists easily handle very large numbers or very small number ...

  4. PAT Basic 1024 科学计数法 (20 分) Advanced 1073 Scientific Notation (20 分)

    科学计数法是科学家用来表示很大或很小的数字的一种方便的方法,其满足正则表达式 [+-][1-9].[0-9]+E[+-][0-9]+,即数字的整数部分只有 1 位,小数部分至少有 1 位,该数字及其指 ...

  5. PAT 甲级 1035 Password (20 分)

    1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...

  6. 1073. Scientific Notation (20)

    题目如下: Scientific notation is the way that scientists easily handle very large numbers or very small ...

  7. PAT 甲级 1050 String Subtraction (20 分) (简单送分,getline(cin,s)的使用)

    1050 String Subtraction (20 分)   Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be t ...

  8. PAT 甲级 1046 Shortest Distance (20 分)(前缀和,想了一会儿)

    1046 Shortest Distance (20 分)   The task is really simple: given N exits on a highway which forms a ...

  9. PAT 甲级 1042 Shuffling Machine (20 分)(简单题)

    1042 Shuffling Machine (20 分)   Shuffling is a procedure used to randomize a deck of playing cards. ...

随机推荐

  1. ORA-01789: 查询块具有不正确的结果列数

    问题描述 ORA-01789: 查询块具有不正确的结果列数 问题原因 sql语句用union时的 两个语句查询的字段不一致,好像顺序也要保持一致才行

  2. 执行PDB的PITR恢复失败的说明

    Oracle 12.1版本中,UNDO表空间仅存在CDB级别(共享UNDO),来自于AskScuti博客园. Oracle 12.2版本开始,UNDO表空间同时可以存在每个PDB级别(本地UNDO). ...

  3. jmeter 登陆--查询存在否-->新建客户-->查询存在否 + 压测

    1.登陆 正则表达式提取器和json提取器,都是后置处理器提取token(都可以在响应中以regexp tester 和 json path tester查看提取的对不对) beanshell 后置处 ...

  4. C++-POJ1017-Packets

    贪心算法,思路见代码 本来想搜索,结果有O(1)的算法,我佛了 其实每一种6x6的方案可以打表预处理,然后dp or search 但是既然可以贪心何乐而不为呢? #include <set&g ...

  5. Android开发实战——记账本(5)

    开发日志——(5)     今天打算将图标的功能实现,将打开图表的选项放在右上方,所以重写MainActivity中的onOptionsItemSelected方法.增添Chart选项 public ...

  6. Codeforces 1207C Gas Pipeline (dp)

    题目链接:http://codeforces.com/problemset/problem/1207/C 题目大意是给一条道路修管道,相隔一个单位的管道有两个柱子支撑,管道柱子高度可以是1可以是2,道 ...

  7. Redis如果内存满了怎么办?

    Redis占用内存大小 我们知道Redis是基于内存的key-value数据库,因为系统的内存大小有限,所以我们在使用Redis的时候可以配置Redis能使用的最大的内存大小. 1.通过配置文件配置 ...

  8. Android输入法挤乱布局问题

    今天做布局的时候 嵌套的TbaleLayout里面有三行  但是准备输入的时候输入法自动将整个activity布局全部往上挤 导致输入框变小甚至消失  弄的很是郁闷 在网上查了之后  发现有些人是因为 ...

  9. php自制工具函数,常用的函数集合

    字符串与爬虫相关 1,解析url /** * 模拟访问,可get可post * @param $curl * @param $postInfo post数组/字符串,不填默认没有post * @par ...

  10. python开发基础01-字符串操作方法汇总

    字符串 Python对字符串的处理内置了很多高效的函数,非常方便功能很强大. "hello world" 字符串七种常用功能: 连接和合并 + join 移除空白  strip 分 ...