码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • PAT甲级 科学计数法


    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
    

    代码长度限制

    16 KB

    时间限制

    200 ms

    内存限制

    64 MB

    1. #include
    2. using namespace std;
    3. int main(){
    4. string origin;
    5. cin>>origin;
    6. char tag1,tag2;
    7. string kuo;
    8. int num;
    9. tag1=origin[0];
    10. if(tag1=='-') cout<<'-';
    11. int j=0;
    12. for(int i=origin.size()-1;i>=0;i--)if(origin[i]=='E') j=i;
    13. tag2=origin[j+1];
    14. kuo = origin.substr(j+2,origin.size());
    15. num = stoi(kuo);
    16. string now=origin.substr(1,j-1);
    17. if(tag2=='+'){
    18. int i=2;
    19. cout<0];
    20. while(num--){
    21. if(i>=now.size()) cout<<'0';
    22. else {
    23. cout<
    24. }
    25. i++;
    26. }
    27. if(now.size()>i){
    28. cout<<'.';
    29. while(isize()){
    30. cout<
    31. i++;
    32. }
    33. }
    34. }else{
    35. if(num==0)cout<
    36. else{
    37. cout<<"0.";
    38. num--;
    39. while(num--)cout<<'0';
    40. for(int i=0;isize();i++){
    41. if(now[i]!='.')cout<
    42. }
    43. }
    44. }
    45. }

  • 相关阅读:
    205.同构字符串
    azkaban邮箱配置
    直播美颜SDK对比评测:技术原理与应用实践
    数据结构线性表之顺序表
    【手撕DroneSSOD】(一)Density Crop Labeling 部分
    题目 94 递归实现排列型枚举
    开发板采集数据后存入数据库再在电脑上显示数据库
    质疑苹果5G信号造假成为闹剧,反而将运营商置于尴尬境地
    三翼鸟三周年:三次升级,全面引领
    基层医院信息管理系统源码 his系统全套成品源码带电子病历4级
  • 原文地址:https://blog.csdn.net/qq_62368250/article/details/134562528
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号