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 ...
随机推荐
- 安装Win8后必做的优化
原版或者精简版的希望都看看安装好Win8后必做的优化:1.关闭家庭组,因为这功能会导致硬盘和CPU处于高负荷状态关闭方法:Win+C – 设置 – 更改电脑设置 – 家庭组 – 离开如果用不到家庭组可 ...
- <youcengcibianli>
#include<stdio.h> #include<stdlib.h> #include<string.h> #define num 100 #define OK ...
- tomcat部署和启动2
catalina run 启动服务器后,按下CTRL+C,停止服务器,选择"y",退回到正常命令行. catalina stop
- Skynet服务器框架(十) CentOS 防火墙设置
引言: 今天修改了 skynet 服务器的 IP 地址(即 config 文件中的 address 和 master 两项参数,IP 与当前及其的保持一致,端口号为 2017),然后使用一个简单的客户 ...
- git中的bug分支和Feature分支
/*游戏或者运动才能让我短暂的忘记心痛,现如今感觉学习比游戏和运动还重要——曾少锋*/ 如果对于分支还不太明白的学者.请先参考:http://www.cnblogs.com/zengsf/p/7512 ...
- 通过Servlet设置文件下载
文件下载 1.获取要下载的文件的绝对路径 但是使用getServletContext().getRealPath()方法在不同的服务器上所获得的实现是不一样的 因为项目被打包入.war文件以后就失去了 ...
- java正则表达式——Greedy、Reluctant和Possessive
测试1: package jichu; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Mai ...
- C#写的window服务内存溢出
浅谈c#垃圾回收机制(GC) 写了一个window服务,循环更新sqlite记录,内存一点点稳步增长.三天后,内存溢出.于是,我从自己的代码入手,查找到底哪儿占用内存释放不掉,最终明确是调用servi ...
- Ubuntu 18.10连接Windows 桌面
========================= 适用于Linux连接Windows远程桌面 Linux版本:CentOS.Ubuntu等 1.终端命令安装远程桌面客户端工具,具体命令如下: sud ...
- java安全性-引用-分层-解耦
Java不支持指针, 一切对内存的访问都必须通过对象的实例变量来实现,这样就防止程序员使用 "特洛伊"木马等欺骗手段访问对象的私有成员 访问一个对象必须通过这个对象的引用 java ...