题意:

给出科学计数法的形式,转化成常规的表示,要求保留所有的有效位数

思路:纯粹的字符串处理问题,注意边界条件即可。如+1.23E+02这种,转化后是123,既不需要补0,也不需要添加小数点。

代码:

#include <iostream>
#include <string>
using namespace std;

string change(string str)
{
    string ans,sign;
    ]=='-') sign="-";
    str.erase(str.begin());

    int pos=str.find("E");
    ,str.size()--pos);
    str=str.substr(,pos);
    int exp=stoi(strExp);

    pos=str.find(".");
    str.erase(pos,);

    ){//前面添0
        ans=,')+str;
    }else{//后面补0
        ;//小数点后面的位数
        ');
        else if(len>exp) {
            ans=str;
            ans.insert(exp+,".");
        }else{
            ans=str;
        }
    }
    return sign+ans;
}

int main()
{
    string str;
    cin>>str;
    cout<<change(str);
    ;
}

1073 Scientific Notation的更多相关文章

  1. PAT 1073 Scientific Notation

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

  2. 1073 Scientific Notation (20 分)

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

  3. PAT 1073 Scientific Notation[字符串处理][科学记数法]

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

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

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

  5. 1073. Scientific Notation (20)

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

  6. PAT Advanced 1073 Scientific Notation (20 分)

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

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

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

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

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

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

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

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

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

随机推荐

  1. Mybatis报错Cause: org.apache.ibatis.executor.ExecutorException: Executor was closed.

    SqlSession被关闭了,检查是否使用了被关闭的SqlSession.

  2. 智课雅思词汇---二十四、形容词后缀-al-ial-ar-ary-ic-id-ish-ile-ine-oid-ory

    智课雅思词汇---二十四.形容词后缀-al-ial-ar-ary-ic-id-ish-ile-ine-oid-ory 一.总结 一句话总结: 1.形容词后缀-al? autumnal 英 [ɔː'tʌ ...

  3. yii2:doajax(post)会报500错误

    yii2:doajax(post)会报500错误:这是因为yii2开启了防御csrf的攻击机制,可去先去掉,在控制器里去掉:public $enableCsrfValidation = false , ...

  4. 【C#笔札】 界面逐渐显现的实现

    如果labview做 就如同上图,so eazy! 现改C#实现这个简单的功能. 在工具箱找到Timer控件 双击 思路如下,界面打开时触发timer事件,每隔一段时间调整界面透明度 开搞 属性框中的 ...

  5. Android DDMS ADB启动失败错误解决!

    ADB server didn't ACK && make sure the plugin is properly configured! adb启动失败一般是端口被占用! 解决方法和 ...

  6. zabbix原理

    数据采集-->数据存储-->数据展示和分析-->报警 数据采集 SNMP agent ICMP/ssh/IPMT数据存储: cacti:rrd nagios:无数据库.mysql z ...

  7. monorepo和multrepo的简介

    项目管理的方式是多种形势的,依据管理的方式类进行项目建仓. mono或者mult其实都是项目管理的方式,只是两种方式是刚好相反的,拿来一起说是,更方便记忆而已. multrepo:将项目分化成为多个模 ...

  8. Redis Web界面管理工具

    Redis Web界面管理工具   一个很友好的Redis Web界面管理工具.基于.NET实现.可以通过Mono部署到Linux上,下面是我部署在CentOS 5.7 + Mono 2.10.8 + ...

  9. http://www.cnblogs.com/peida/archive/2013/05/31/3070790.html深入理解Java:SimpleDateFormat安全的时间格式化

    http://www.cnblogs.com/peida/archive/2013/05/31/3070790.html

  10. FLASH动作脚本详解

    FLASH动作脚本详解 一.FLASH脚本基础入门讲解 二.按钮AS的编写 三.影片剪辑的AS编写 四.动态文本框 五.影片剪辑的拖拽 六.流程控制与循环语句 七.绘图及颜色的AS的编写 八.声音 A ...