国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

PAT A1073. Scientific Notation (20)

2019-11-11 02:08:24
字體:
來源:轉載
供稿:網友

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 <cstdio>#include <algorithm>#include <cmath>#include <cstring>#define Max 100001using namespace std;int main(){	char a[Max],b[Max],c[Max];	int z=-1,f=0,bf=0,cf=0,y=-1;	int m,n=0,x,d,nm=0;	int num[Max];	scanf("%s",a);	if(a[0]=='-') printf("-");	m=a[0];	for(int i=3;i<strlen(a);i++)	{		if(a[i]=='E') { 			x=i-3;			d=i;			f=1;		   		}		else if(f==0)		{			b[bf++]=a[i];		}		else if(f==2&y!=-1)		{			c[cf++]=a[i];		}		else if(f==1)		{			f=2;			if(a[i]=='-'){				y=0;			}			else if(a[i]='+'){				y=1;			}		}			}	for(int i=0;i<strlen(a);i++)	{		if(a[i]>='0'&&a[i]<='9')			num[nm++]=a[i]-'0';		if(a[i]=='E')  break;	}	for(int i=0;i<cf;i++)	{		n=n*10+(c[i]-'0');	}	if(y==0)	{		n=n+bf-1;		printf("0.");		for(int i=0;i<=n-nm;i++)  printf("0");		for(int i=0;i<nm;i++) printf("%d",num[i]);		printf("/n");	}	else if(y==1)	{		if(n>bf){			n=n-bf;	        for(int i=0;i<nm;i++) printf("%d",num[i]);			for(int i=0;i<n;i++) printf("0");		}		else {			n=bf-n;			for(int i=0;i<nm-n;i++) {printf("%d",num[i]); z=i;}			 if(z<nm-1) printf(".");			for(int i=nm-n;i<nm;i++) printf("%d",num[i]);		}		printf("/n");	}	system("pause");	return 0;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 金坛市| 赤水市| 汝城县| 凌云县| 许昌县| 定西市| 阿图什市| 宁强县| 都江堰市| 沈阳市| 安远县| 隆尧县| 菏泽市| 青州市| 应用必备| 贵阳市| 台南县| 金湖县| 濮阳县| 镇宁| 福安市| 怀宁县| 宜州市| 太和县| 如皋市| 五原县| 丰原市| 宁城县| 汪清县| 商水县| 万盛区| 石城县| 龙里县| 崇左市| 罗田县| 新泰市| 长宁县| 大悟县| 阳城县| 南郑县| 于田县|