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

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

PAT A1073. Scientific Notation (20)

2019-11-11 03:20:55
字體:
來源:轉載
供稿:網友

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;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 易门县| 岑溪市| 织金县| 长汀县| 通辽市| 乌海市| 芜湖市| 彰化县| 鞍山市| 贵溪市| 双桥区| 勃利县| 苏州市| 玉林市| 山阴县| 循化| 罗城| 旌德县| 六安市| 台东县| 新乡县| 吉安市| 彩票| 砚山县| 东丰县| 资兴市| 四会市| 金塔县| 六盘水市| 瑞金市| 宁武县| 凌源市| 新晃| 通许县| 时尚| 新郑市| 白朗县| 清水县| 岢岚县| 株洲市| 璧山县|