PAT_A1073#Scientific Notation
Source:
Description:
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
Keys:
- 字符串处理
Code:
#include<cstdio>
#include<string>
#include<iostream>
using namespace std; int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("Test.txt", "r", stdin);
#endif // ONLINE_JUDGE string s;
cin >> s;
int pos = s.find('E');
string fra = s.substr(,pos);
int exp = atoi(s.substr(pos+).c_str());
fra.erase(,);
if(exp > )
{
int len = exp+-fra.size();
if(len>)
for(int i=; i<len; i++)
fra.insert(fra.end(),'');
else
fra.insert(fra.begin()+exp+,'.');
}
else
{
for(int i=; i>exp; i--)
fra.insert(fra.begin()+,'');
fra.insert(fra.begin()+,'.');
}
if(fra[]=='+')
fra.erase(,);
cout << fra; return ;
}
PAT_A1073#Scientific Notation的更多相关文章
- Excel scientific notation issue
This is a known issue, you can find more in internet. Excel will treat text(can display with num ...
- 1073. Scientific Notation (20)
题目如下: Scientific notation is the way that scientists easily handle very large numbers or very small ...
- PAT 1073 Scientific Notation
1073 Scientific Notation (20 分) Scientific notation is the way that scientists easily handle very ...
- PAT A1073 Scientific Notation (20 分)——字符串转数字
Scientific notation is the way that scientists easily handle very large numbers or very small number ...
- A1073. Scientific Notation
Scientific notation is the way that scientists easily handle very large numbers or very small number ...
- 1073 Scientific Notation (20 分)
1073 Scientific Notation (20 分) Scientific notation is the way that scientists easily handle very la ...
- PAT 1073 Scientific Notation[字符串处理][科学记数法]
1073 Scientific Notation(20 分) Scientific notation is the way that scientists easily handle very lar ...
- PAT 甲级 1073 Scientific Notation (20 分) (根据科学计数法写出数)
1073 Scientific Notation (20 分) Scientific notation is the way that scientists easily handle very ...
- PAT Advanced 1073 Scientific Notation (20 分)
Scientific notation is the way that scientists easily handle very large numbers or very small number ...
随机推荐
- web开发jsp页面遇到的一系列问题
一:web总结 1.jsp页面知识点巩固 1.1字符串数字格式化转换 <%@ taglib prefix="fmt" uri="http://java.sun.co ...
- Python入门习题8.羊车门问题
例8. 羊车门问题描述:有3扇关闭的门,一扇后停着汽车,另外两扇门后是山羊,主持人知道每扇门后是什么.参赛者首先选择一扇门.在开启它之前,主持人会从另外两扇门中打开一扇门,露出门后的山羊.此时,允许参 ...
- [poj3074]Sudoku(舞蹈链)
题目链接:http://poj.org/problem?id=3074 舞蹈链精确覆盖的经典题目,一个数独每个位置的要求,可以得到以下四个约束1.每个位置有且只有一个数字2.每个位置的数字在一行只能出 ...
- Java 8实战之读书笔记四:高效Java 8编程
三.高效Java 8编程 第8章 重构.测试和调试 Java 8的新特性也可以帮助提升代码的可读性: 使用Java 8,你可以减少冗长的代码,让代码更易于理解 通过方法引用和S ...
- indexDB的概念
IndexDB利用数据键(key)访问,通过索引功能搜索数据,适用于大量的结构化数据,如日历,通讯簿或者记事本. 1. 以key/value成对保存数据 IndexDB和WebStorage都是以数据 ...
- 2018-8-10-win10-uwp-线程池
title author date CreateTime categories win10 uwp 线程池 lindexi 2018-08-10 19:16:50 +0800 2018-05-15 1 ...
- Shell07--正则应用
目录 1. 正则表达式概述 2. 正则表达式规则 3. 正则表达式之GREP文本过滤 4. 正则表达式之SED文本处理 5. 正则表达式之AWK文本处理 1. 正则表达式概述 01. 什么是正则表达式 ...
- 解决Minikube start卡住的方法
安装与问题 在mac上安装minikube对k8s进行学习,根据官方Quick Start brew cask install minikube 就可以完成minikube的安装 在安装前需要安装vi ...
- 【python实例】要求输出字符串中最少一个最多八个的所有字符串组合(连续)
""" 题目:字符串str="ABCDEFGHIJK",要求输出最少一个最多八个的所有组合(向后连续字母) 输出如下: A [0::] AB ABC ...
- 不在同一个解决方案下的exe去调试dll,采用附加到进程:
先把dll的项目生成一下,把得到的pdb,dll文件复制到exe目录下,然后直接双击运行exe(不是通过vs启动),再接着在dll的项目中”调试”->”附加到进程”,选择刚才运行的exe. 注意 ...