1073 Scientific Notation (20 分)
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
分析:字符串处理题,按题意改就行了。代码改了好多次。。。可能只有我自己能看懂了吧。。20分的题debug了半小时。。。
/** * Copyright(c) * All rights reserved. * Author : Mered1th * Date : 2019-02-24-16.27.04 * Description : A1073 */ #include<cstdio> #include<cstring> #include<iostream> #include<cmath> #include<algorithm> #include<string> #include<unordered_set> #include<map> #include<vector> #include<set> using namespace std; int main(){ #ifdef ONLINE_JUDGE #else freopen("1.txt", "r", stdin); #endif string s,ans=""; cin>>s; ]=='-'){ printf("-"); } s.erase(s.begin()); int i,len=s.length(),k,p; ;i<len;i++){ '){ ans+=s[i]; } else if(s[i]=='.'){ k=i; //记录小数点位置 continue; } else if(s[i]=='E') { p=i; //记录E的位置 break; } } bool flag=true; ]=='-') flag=false; s.erase(i,); //删除E和指数符号 string e=""; ;i++){ e=e+s[i]; } int E=stoi(e); if(flag==false){ printf("0."); ;j<E-;j++){ printf("); } cout<<ans; } if(flag==true){ ==E){ cout<<ans; } <E){ cout<<ans; ;j<E-;j++){ printf("); } } else{ )-E+,m; ;m<a;m++){ printf("%c",ans[m]); } printf("."); for(;m<ans.size();m++){ printf("%c",ans[m]); } } } ; }
1073 Scientific Notation (20 分)的更多相关文章
- 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 ...
- PAT Basic 1024 科学计数法 (20 分) Advanced 1073 Scientific Notation (20 分)
科学计数法是科学家用来表示很大或很小的数字的一种方便的方法,其满足正则表达式 [+-][1-9].[0-9]+E[+-][0-9]+,即数字的整数部分只有 1 位,小数部分至少有 1 位,该数字及其指 ...
- PAT甲级——1073 Scientific Notation (20分)
Scientific notation is the way that scientists easily handle very large numbers or very small number ...
- 【PAT甲级】1073 Scientific Notation (20 分)
题意: 输入科学计数法输出它表示的数字. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> u ...
- 1073. Scientific Notation (20)
题目如下: Scientific notation is the way that scientists easily handle very large numbers or very small ...
- PAT甲题题解-1073. Scientific Notation (20)-字符串处理
题意:给出科学计数法的格式的数字A,要求输出普通数字表示法,所有有效位都被保留,包括末尾的0. 分两种情况,一种E+,一种E-.具体情况具体分析╮(╯_╰)╭ #include <iostrea ...
- PAT (Advanced Level) 1073. Scientific Notation (20)
简单模拟题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...
- PAT 1073 Scientific Notation
1073 Scientific Notation (20 分) Scientific notation is the way that scientists easily handle very ...
随机推荐
- Android RIL结构分析与移植
介绍 本文档对Android RIL部分的内容进行了介绍,其重点放在了Android RIL的原生代码部分. 包括四个主题: 1.Android RIL框架介绍 2.Android RIL与 Wind ...
- python Gevent – 高性能的Python并发框架
话说gevent也没个logo啥的,于是就摆了这张图= =|||,首先这是一种叫做greenlet的鸟,而在python里,按照官方解释greenlet是轻量级的并行编程,而gevent呢,就是利用g ...
- 步步入佳境---UI入门(1)--项目建立与实现
一,本文讲解建立一个空项目,怎么一步一步的创建程序,总体的感觉一下程序流程 1,首先建立一个项目,如下:single view project,我们首先删除CHAppDelegate文件和Main. ...
- liunx用户管理的基本命令
1.passwd 修改用户密码 2.useradd 用户组名 增加用户组 3.su 用户名 切换用户名 4.usermod 用户更改 5.userdel 用户删除
- 查找单链表的倒数第k个值
刚开始,我想到的是一种笨方法,先遍历单链表,计算出单链表的长度len,然后再从头遍历单链表到第len-k个节点,那么 这个节点既是单链表的倒数第k个节点. 不过这种算法时间复杂度挺高的,还有一种更简单 ...
- 20155229 2016-2017-2 《Java程序设计》第六周学习总结
20155229 2016-2017-2 <Java程序设计>第六周学习总结 教材学习内容总结 第十章 Java中,输入串流代表对象为java.io.InputStream,输出串流代表对 ...
- HDU 5178:pairs(二分,lower_bound和upper_bound)
pairs Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Subm ...
- ElasticSearch(七):ElasticSearch集群的搭建
由于资源有限,使用是一台机器上安装三个elasticSearch服务端组成的集群. 1. 安装elasticSearch6.3.2 将原本安装的elasticSearch6.3.2复制两份,分别重新命 ...
- 使用Visual Studio Code开发Asp.Net Core WebApi学习笔记(三)-- Logger
本篇是在上一篇的基础上添加日志功能,并记录NLog在Asp.Net Core里的使用方法. 第一部分:默认Logger支持 一.project.json添加日志包引用,并在cmd窗口使用 dotnet ...
- Eclipse使用前准备(转)
Eclipse的发布流程 M1 08/19/2009 M2 09/30/2009 M3 11/11/2009 M4 12/16/2009 M ...