1. #include <iostream>
  2. using namespace std;
  3. string a;
  4. int expo;
  5. int dotPos;
  6. int expoPos;
  7. int i;
  8. int main(){
  9. cin>>a;
  10. if(a[0]=='+'||a[0]=='-'){
  11. if(a[0]=='-'){cout<<"-";}
  12. a.erase(a.begin());
  13. }
  14. for(i=0;i<a.size();i++){
  15. if(a[i]=='.'){
  16. dotPos=i;
  17. }
  18. if(a[i]=='E'){
  19. expoPos=i;
  20. break;
  21. }
  22. }
  23. string expoStr=a.substr(expoPos+1);
  24. expo=stoi(expoStr);
  25. string b=a.substr(0,expoPos);
  26. b.erase(b.begin()+dotPos);
  27. if(expo>0){
  28. if((expoPos-dotPos)<=(expo+1)){
  29. cout<<b;
  30. int count=expo-(expoPos-dotPos)+1;
  31. while(count--){cout<<"0";}
  32. }else{
  33. int i=0;
  34. i+=expo+1;
  35. b.insert(i,".");
  36. cout<<b<<endl;
  37. }
  38. }else if(expo<0){
  39. expo++;
  40. cout<<"0.";
  41. while(expo!=0){
  42. cout<<"0";
  43. expo++;
  44. }
  45. cout<<b<<endl;
  46. }else{
  47. cout<<a.substr(0,expoPos);
  48. }
  49.  
  50. return 0;
  51. }

PAT1073. Scientific Notation (20)的更多相关文章

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

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

  2. 1073. Scientific Notation (20)

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

  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甲级——1073 Scientific Notation (20分)

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

  6. PAT (Advanced Level) 1073. Scientific Notation (20)

    简单模拟题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...

  7. PAT甲题题解-1073. Scientific Notation (20)-字符串处理

    题意:给出科学计数法的格式的数字A,要求输出普通数字表示法,所有有效位都被保留,包括末尾的0. 分两种情况,一种E+,一种E-.具体情况具体分析╮(╯_╰)╭ #include <iostrea ...

  8. 【PAT甲级】1073 Scientific Notation (20 分)

    题意: 输入科学计数法输出它表示的数字. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> u ...

  9. PAT 1073 Scientific Notation

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

随机推荐

  1. 【BZOJ4384】[POI2015]Trzy wieże 树状数组

    [BZOJ4384][POI2015]Trzy wieże Description 给定一个长度为n的仅包含'B'.'C'.'S'三种字符的字符串,请找到最长的一段连续子串,使得这一段要么只有一种字符 ...

  2. [LintCode] 两个排序数组的中位数

    class Solution { public: /** * @param A: An integer array. * @param B: An integer array. * @return: ...

  3. vue学习之旅:入门

    首先利用脚手架vue cli搭建vue环境 引入 vue <script src="https://unpkg.com/vue/dist/vue.js"></sc ...

  4. delphi ---ttoolbar,ttoolbutton

    1.button style:tbsButton,tbsCheck,tbsDivider,tbsDropDown,tbsSeparator,tbsTextButton tbsButton:普通的控件 ...

  5. convention over configuration 约定优于配置 按约定编程 约定大于配置 PEP 20 -- The Zen of Python

    为什么说 Java 程序员必须掌握 Spring Boot ?_知识库_博客园 https://kb.cnblogs.com/page/606682/ 为什么说 Java 程序员必须掌握 Spring ...

  6. 【转】Mysql的配置文件详解

    [client]port = 3306socket = /tmp/mysql.sock [mysqld]port = 3306socket = /tmp/mysql.sock basedir = /u ...

  7. 【MonogDB】The description of index(二) Embedded and document Index

    In this blog, we will talk about another the index which was called "The embedded ". First ...

  8. windows下的Mysql安装与基本使用(msi)

    一.安装方式 1.msi(其他版本:https://www.cnblogs.com/zjiacun/p/6653891.html) 2.zip 这里我们用msi吧,只是单纯练习的话,简单很多 二.ms ...

  9. BeanUtils.copyProperties()

    BeanUtils.copyProperties() PropertyUtils.copyProperties() 通过反射将一个对象的值赋值个另外一个对象(前提是对象中属性的名字相同). 后付前 P ...

  10. (转)live555在Linux下最简单地实现实时流媒体点播

    通过Live555交叉编译后运行发现,上面实现的流媒体实时通过文件服务器的文件点播,没有相关的流媒体实现方式, 但在Linux下,可以通过某些技巧实现Live555服务器实时流媒体服务器,并且是傻瓜式 ...