Scientific notation is the way that scientists easily handle very large numbers or very small numbers. The notation matches the regular expression [+-][1-9].[0-9]+E[+-][0-9]+ which means that the integer portion has exactly one digit, there is at least one digit in the fractional portion, and the number and its exponent's signs are always provided even when they are positive.

Now given a real number A in scientific notation, you are supposed to print A in the conventional notation while keeping all the significant figures.

Input Specification:

Each input contains one test case. For each case, there is one line containing the real number A in scientific notation. The number is no more than 9999 bytes in length and the exponent's absolute value is no more than 9999.

Output Specification:

For each test case, print in one line the input number A in the conventional notation, with all the significant figures kept, including trailing zeros.

Sample Input 1:

+1.23400E-03

Sample Output 1:

0.00123400

Sample Input 2:

-1.2E+10

Sample Output 2:

-12000000000

 #include <stdio.h>
#include <map>
#include <algorithm>
#include <iostream>
#include <string>
#include <math.h>
using namespace std; int main(){
string a;
cin >> a;
if (a[] == '-'){
printf("-");
a.erase(, );
}
else if (a[] == '+'){
a.erase(, );
}
a.erase(, );
int pos_e;
pos_e = a.find('E');
string sub_str = a.substr(pos_e + , a.length() - pos_e - );
int flag = ;
if (sub_str[] == '-')flag = -;
a.erase(pos_e, + sub_str.length());
sub_str.erase(, );
while (!sub_str.empty() && sub_str[] == ''){
sub_str.erase(, );
}
int exp = ;
if (sub_str.empty())exp = ;
else{
for (int i = ; i < sub_str.length(); i++){
exp = exp * + sub_str[i] - '';
}
}
int extra = ;
if (flag == -){
for (int i = ; i < exp - ; i++){
a.insert(, "");
}
a.insert(,"0.");
}
else{
int l = a.length(); if (exp >= l - ){
for (int i = ; i < exp - l+;i++){
a.insert(a.length(),"");
} }
else{
a.insert( + exp, ".");
}
}
cout << a;
system("pause");
}

注意点:和B1024一样,就是分情况实现,字符串转数字,要记得字符串的find,erase,substr操作。

PAT A1073 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 Advanced 1073 Scientific Notation (20 分)

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

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

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

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

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

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

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

  6. PAT 1073 Scientific Notation

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

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

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

  8. PAT甲级——A1073 Scientific Notation

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

  9. 1073. Scientific Notation (20)

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

随机推荐

  1. 【Tomcat】Tomcat日志切割

    下载并解压缩 cronolog # tar zxvf cronolog-1.6.2.tar.gz 2.进入cronolog安装文件所在目录 # cd cronolog-1.6.2 3.运行安装  # ...

  2. 【Spring】12、Spring Security 四种使用方式

    spring security使用分类: 如何使用spring security,相信百度过的都知道,总共有四种用法,从简到深为:1.不用数据库,全部数据写在配置文件,这个也是官方文档里面的demo: ...

  3. kafka结合Spark-streming的直连(Direct)方式

     说明:此程序使用的scala编写 在spark-stream+kafka使用的时候,有两种连接方式一种是Receiver连接方式,一种是Direct连接方式. 两种连接方式简介: Receiver接 ...

  4. js 如何移除一个匿名函数的绑定事件

    大家都知道 addEventListener的用法 绑定事件 例如 element.addEventListener(type,handler,false); element是dom元素 type是事 ...

  5. canvas-star5.html

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. Java:JDBC的基本使用

    本文内容: 什么是JDBC JDBC的使用 事务 连接池 DbUtils 首发日期:2018-05-27 修改: 2018-07-19:增加了事务.连接池.DBUtils 2018-07-27:对特别 ...

  7. pycharm运行Django发生AppRegistryNotReady: Apps aren't loaded yet.

    pycharm中运行django默认情况下并不是执行项目的,所以如果在非manage.py,会发生异常. raise AppRegistryNotReady("Apps aren't loa ...

  8. VMware-workstation12.5.6 新建虚拟机 安装 centos6.5

    1.到官方下载镜像文件 注意:看到上面那两个红框不要着急复制链接用迅雷下载,因为点击进去是个页面,不知道官方做这个用意是怎样的,个人感觉很傻缺我们只要点击第一个红框就行 *************** ...

  9. [20171031]rman xxx Failure.txt

    [20171031]rman xxx Failure.txt --//简单测试 List Failure, Advise Failure and Repair Failure命令在11g下,也许以后工 ...

  10. python第十六天,昨天来晚了,作业终于完成了

    作业 1: 员工信息表程序,实现增删改查操作 可进行模糊查询,语法至少支持下面3种: select name,age from staff_table where age > 22 select ...