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 分)的更多相关文章

  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. 1073. Scientific Notation (20)

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

  7. PAT甲题题解-1073. Scientific Notation (20)-字符串处理

    题意:给出科学计数法的格式的数字A,要求输出普通数字表示法,所有有效位都被保留,包括末尾的0. 分两种情况,一种E+,一种E-.具体情况具体分析╮(╯_╰)╭ #include <iostrea ...

  8. PAT (Advanced Level) 1073. Scientific Notation (20)

    简单模拟题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...

  9. PAT 1073 Scientific Notation

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

随机推荐

  1. Swift网络封装库Moya中文手册之Targets

    Targets 使用Moya,我们首先需要定义一个target - 这通常是继承 TargetType 协议的 枚举 变量.接下来,你的app只需要处理这些targets,也就是一些你希望调用API完 ...

  2. 【重大更新】DevExpress v17.2新版亮点—WinForms篇(二)

    用户界面套包DevExpress v17.2终于正式发布,本站将以连载的形式为大家介绍各版本新增内容.开篇介绍了DevExpress WinForms v17.2 Data Grid Control ...

  3. 2019.1.10 L223

    Heavy rains that brought additional pollution downstream last year contributed to the first decline ...

  4. iOS-----推送机制(下)

    推 送 机 制(下) 单击”从证书颁发机构请求证书”后,将会显示下图所示的对话框 输入电子邮件地址和常用名称,并选中“存储到磁盘”单选钮,然后单击“继续”按钮,该程序将会创建一个“Certificat ...

  5. I.MX6 working note for high efficiency

    /**************************************************************************** * I.MX6 working note f ...

  6. MATLAB安装教程

    1.资源下载 下载官方安装包R2015b_win64.(文件太大,没上传资源) 下载破解文件包,解压其中的相应压缩包(一般是win64那个压缩包) 下载地址:链接:http://pan.baidu.c ...

  7. C# 处理DateTime算法,取某月第1天及最后一天

    代码如下所示: /// <summary> /// 取得某月的第一天 /// </summary> /// <param name="datetime" ...

  8. element组件知识点总结

    1:单选框与多选框的change事件,html代码 <div id="app"> <div class="demo box"> < ...

  9. CentOS升级Python2.6到Python2.7并安装pip

    原文:http://ruter.sundaystart.net/2015/12/03/Update-python/ 貌似CentOS 6.X系统默认安装的Python都是2.6版本的?平时使用以及很多 ...

  10. vs2013下OpenGL环境的配置

    1.下载glut库:https://files.cnblogs.com/files/laoxia/glutdlls37beta.zip 2.解压后,将glut.lib和glut32.lib两个文件拷贝 ...