1073. Scientific Notation (20)
来源:互联网 发布:监控网络拓扑图 编辑:程序博客网 时间:2024/05/16 16:00
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 file 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-03Sample Output 1:
0.00123400Sample Input 2:
-1.2E+10Sample Output 2:
-12000000000
#include<stdio.h>#include<string.h>int main(){ char c,a[10005]; int sum=0,i,e,j; scanf("%c%s",&c,a); if (c=='-') printf("-"); for (i=0;i<strlen(a);i++) { if (a[i]=='E') e=i; } for (i=e+2;i<strlen(a);i++) sum=sum*10+(a[i]-'0'); if(sum!=0) { if (a[e+1]=='-') { printf("0."); for (i=0;i<sum-1;i++) printf("0"); printf("%c",a[0]); for (i=2;i<e;i++) printf("%c",a[i]); } else { printf("%c",a[0]); if(sum<(e-1)) { for (i=2;i<sum+2;i++) printf("%c",a[i]); if((sum+2)!=e) printf("."); for (i=sum+2;i<e;i++) printf("%c",a[i]); } else { for (i=2;i<e;i++) printf("%c",a[i]); for (i=0;i<=sum-(e-1);i++) printf("0"); } } } else { for (i=0;i<e;i++) printf("%c",a[i]); } return 0;}
- 1073. Scientific Notation (20)
- 1073. Scientific Notation (20)
- 1073. Scientific Notation (20)
- 1073. Scientific Notation (20)
- 1073. Scientific Notation (20)
- 1073. Scientific Notation (20)
- 1073. Scientific Notation (20)
- 1073. Scientific Notation (20)
- 1073. Scientific Notation (20)
- 1073. Scientific Notation (20)
- 1073. Scientific Notation (20)
- 1073. Scientific Notation (20)
- 1073. Scientific Notation (20)
- 1073. Scientific Notation (20)
- 1073. Scientific Notation (20)
- 1073. Scientific Notation (20)
- 1073. Scientific Notation (20)
- 1073. Scientific Notation (20)
- 邮件发送
- CCAI 2017 | 香港科技大学计算机系主任杨强:论深度学习的迁移模型
- JavaScript HTML DOM 元素(节点)/添加和删除节点(HTML 元素)。
- Android 中Message,MessageQueue,Looper,Handler详解+实例
- shiro简单配置
- 1073. Scientific Notation (20)
- hdu 2022 海选女主角
- 《算法》第四版 初学习惯调整 记录
- [spring-boot] 集成shiro (二)
- 点评:系统集成不需要Common Data Model(CDM)吗?
- 1 Github入门
- 电脑键盘上三个指示灯代表什么意思?
- java基础入门补充(001) native方法
- css reset总结