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

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

PAT A1073. Scientific Notation (20)

2019-11-11 01:33:13
字體:
來源:轉載
供稿:網友

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;}
上一篇:poj1163

下一篇:poj1163

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 武义县| 南木林县| 会宁县| 普兰店市| 寿阳县| 泰州市| 浮山县| 兴文县| 大新县| 印江| 安庆市| 洛南县| 景德镇市| 共和县| 赤壁市| 宁阳县| 新乡县| 夹江县| 周宁县| 高阳县| 江北区| 武宣县| 儋州市| 康乐县| 承德县| 镇康县| 昌平区| 都兰县| 千阳县| 南昌县| 大埔区| 赤水市| 思南县| 江西省| 三门峡市| 新源县| 六安市| 积石山| 安阳县| 岳普湖县| 合阳县|