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 ...
随机推荐
- core servlets & server pages 上面的HttpClient GUI工具
我没怎么细读源码,等下次详细看的时候将这句话去掉. import java.awt.*; import java.awt.event.*; import java.io.*; import java. ...
- html5、canval 对 图片的压缩
let src = this.cropper.getCroppedCanvas().toDataURL('image/jpeg');let can = document.createElement(' ...
- 升级 macOS Mojave 后部分软件 (如 VS Code) 字体变虚的解决方法
目前有些朋友的设备可能还是“非 Retina” 显示器,那这样如果升级到 Mojave 后你会发现文字不清晰了,这是因为 Mojave 默认关闭了文字次像素渲染字体,你需要在终端里执行: defaul ...
- GPIO口的输入输出模式
1.浮空输入 GPIO_Mode_IN_FLOATING 2.带上拉输入 GPIO_Mode_IPU 3.带下拉输入 GPIO_Mode_IPD 4.模拟输入 ...
- 初识Tarjan算法
#include<bits/stdc++.h> using namespace std; ; ;//强连通分量的个数 int stk[maxn];//暂时存放遍历过的点,在遇到low[x] ...
- test20181005 序列
题意 考场30分 维护差值,考虑每次移动的变更,当前2-n位置上的差加1,1位置上的差减n-1. 然后要求的是绝对值的和,用吉司机线段树维护最大最小值.次大次小值. 期望复杂度\(O(n \log n ...
- Vue中的“混合”——mixins使用方法
混合是一种灵活的分布式复用 Vue 组件的方式.混合对象可以包含任意组件选项.以组件使用混合对象时,所有混合对象的选项将被混入该组件本身的选项.当组件和混合对象含有同名选项时,这些选项将以恰当的方式混 ...
- Android USB gadget框架学习笔记
一 Gadget框架结构 kernel/drivers/usb/gadget,这个目录是android下usbgadget的主要目录. Gadget功能组织单元:主要文件android.c,usb g ...
- asp.net excel 操作
/// <summary> /// 数据操作 /// </summary> /// <param name="fileName"></pa ...
- ECHO不换行
我想用批处理实现向s.txt中多次分别导入文本例如:“aaaa","bbbb","cccc","dddd"实现s.txt内效果如: ...