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. <小常识>

    1,DOS(磁盘操作系统) 2,人机交互: (1):图形化界面(Graphical User interface GUI), (2):命令行方式(Command Line Interface CLI) ...

  2. 三步解决 vue 按需加载

    1  webpack 的 output 配置 chunkFleName 树干名称: " chunks/[name]-[chunkhash:8].js  " 这一步是配合第三步, 生 ...

  3. FMX StringGrid向上滑动自动加载记录(一)

    有时候,做的app还是需要用StringGrid来显示数据,但如果用StringGrid的Livebinding绑定到一个数据集TDataset,当记录超过1000条时,效率非常低,甚至达不到实用状态 ...

  4. NBUT 1223 Friends number 2010辽宁省赛

    Time limit  1000 ms Memory limit   131072 kB Paula and Tai are couple. There are many stories betwee ...

  5. 转:AMD规范与CMD规范的区别是什么?

    AMD规范与CMD规范的区别是什么?    在比较之前,我们得先来了解下什么是AMD规范?什么是CMD规范?当然先申明一下,我个人也是总结下而已,也是网上看到的资料,自己总结下或者可以说整理下而已,供 ...

  6. 第十五篇 make中的隐式规则概述

      前面我们讲到了makefile的依赖拆分的知识,现在可以引申出这样一个问题,如果同一个目标的不同命令拆分的写到不同地方会发生什么?下面我们给出程序和执行结果:   可见后面的命令会覆盖前面的命令, ...

  7. DS博客作业04--树大作业说明

    大作业题目说明 1.目录树 按照如下目录路径,设计一颗目录树保存.并能实现对目录树遍历.目录路径存在file.txt,格式如下: b.txt c\ ab\cd.txt a\bc.txt ab\d.tx ...

  8. 字符串的比较【string和字符数组】

    无论是string 还是 字符数组的字符串比较函数,返回的都是字典序的大小.如 1234 和 5 比较时就是1234的字典序小于5,要想比较字符串表示的数字的大小,需要自己写函数比较

  9. 图片加载完毕后执行JS代码

    $("#img").load(function(){...}); 这是jquery提供的一个方法,但是在IE中会有BUG,IE8不支持,IE9以上刷新后也不会执行,只有强制刷新才执 ...

  10. cuda+ffmpeg+opengl解码rtsp h264码流多路

    Cuda 解码 全尺寸 解码 .全尺寸窗口绘制测试( 分别 测试 视频 文件和 IP 相机 实时视频 ) 1080 p 视屏 文件 全尺寸 解码 全尺寸 显示 72 0p IP 相机 全尺寸 解码 全 ...