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

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

PAT A1073. Scientific Notation (20)

2019-11-11 02:10: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
#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;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 社旗县| 岑巩县| 靖宇县| 恭城| 夏邑县| 泊头市| 桦甸市| 岱山县| 三亚市| 马边| 郎溪县| 威远县| 陕西省| 密山市| 阳原县| 太保市| 鹤庆县| 邢台市| 肥乡县| 康马县| 临安市| 秦皇岛市| 泉州市| 翼城县| 翁源县| 溧水县| 南靖县| 新建县| 长岛县| 甘谷县| 祁门县| 禄劝| 中超| 德清县| 安阳县| 保山市| 永城市| 阜南县| 广安市| 从化市| 南靖县|