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

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

PAT A1073. Scientific Notation (20)

2019-11-11 02:09:19
字體:
來源:轉載
供稿:網友

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;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阿瓦提县| 托克托县| 义马市| 南陵县| 玉龙| 安义县| 澎湖县| 福贡县| 嘉祥县| 武邑县| 云安县| 鄂温| 余庆县| 建宁县| 渑池县| 闸北区| 开封市| 安岳县| 沁阳市| 昔阳县| 班玛县| 宁陵县| 甘肃省| 莆田市| 修武县| 岳西县| 古田县| 金溪县| 大丰市| 宁明县| 庄浪县| 甘洛县| 新蔡县| 巨鹿县| 伊吾县| 定南县| 巴塘县| 茌平县| 嘉兴市| 咸宁市| 沂水县|