1073. Scientific Notation (20)
来源:互联网 发布:vscode 导出配置 编辑:程序博客网 时间:2024/05/16 17:37
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
//1073#include<iostream>using namespace std;int main(){char num[10000];int k;//char positive;//'+' or '-' flagscanf("%c",&positive);int i=0;//record the effective length of numwhile(1){scanf("%c",num+i);if(num[i]=='E')break;if(num[i]!='.')++i;}num[i]='\0';scanf("%d",&k);if(positive=='-')printf("%c",positive);if(k==0){//k=0, print the original num with dotprintf("%c.",num[0]);int j=1;while(num[j]!='\0')printf("%c",num[j++]);}else if(k<0){//if k<0, print corresponding number of '0' before numprintf("0.");for(int j=0;j<-k-1;++j)printf("0");printf("%s",num);}else{//if k>0, be care of dot and '0' int the backfor(int j=0;j<i || j<=k;++j){//i is the effective length of numif(j==k+1)printf(".");if(j>=i)//the length of effective digit is less than kprintf("0");elseprintf("%c",num[j]);}}printf("\n");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)
- 1072. Gas Station (30)
- 算法导论 - 最大和连续子数组
- jasperreport linux 中文不能显示的解决方法
- Delegate,Action,Func,Predicate的使用与区别
- JavaScript前端编码Java后端解码
- 1073. Scientific Notation (20)
- UVA 106 Fermat vs. Pythagoras(勾股数)
- 1074. Reversing Linked List (25)
- H2数据库攻略之三-结合Maven
- Wince stepldr代码解析
- 欢迎使用CSDN-markdown编辑器
- CSS规范
- Android 插件化技术 加载任意未安装apk
- 黑马程序员--04C预处理