其他分享
首页 > 其他分享> > Exponential notation (模拟)

Exponential notation (模拟)

作者:互联网

You are given a positive decimal number x.

Your task is to convert it to the "simple exponential notation".

Let x = a·10b, where 1 ≤ a < 10, then in general case the "simple exponential notation" looks like "aEb". If b equals to zero, the part "Eb" should be skipped. If a is an integer, it should be written without decimal point. Also there should not be extra zeroes in a and b.

Input

The only line contains the positive decimal number x. The length of the line will not exceed 106. Note that you are given too large number, so you can't use standard built-in data types "float", "double" and other.

Output

Print the only line — the "simple exponential notation" of the given number x.

Examples

Input

16

Output

1.6E1

Input

01.23400

Output

1.234

Input

.100

Output

1E-1

Input

100.

Output

1E2

这里就是找到  .  的位置,然后看  .  移动的距离

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<vector>
#include<cmath>
const int maxn=1e5+5;
typedef long long ll;
using namespace std;
int main(){
	string str;
	cin>>str;
	int len=str.length() ;
	int l=-1,r=len-1,num=0,point=-1;
	
	for(int i=0;i<len;i++){//找到.的位置 
		if(str[i]=='.'){
			point=i;
			break;
		}
	}
	if(point==-1)//  式子中没有 . 
	    point=len;
	for(int i=0;i<len;i++){//从左边找第一个不是0 的数 
		if(str[i]!='0'&&str[i]!='.'){
			l=i;
			break;
		}
	}
    for(int i=len-1;i>=0;i--){//从右边找第一个不是0 的数 
    	if(str[i]!='0'&&str[i]!='.'){
    		r=i;
    		break;
		}
	} 
	//cout<<point<<endl;
    if(l==-1)
        cout<<"0"<<endl;//没有不是0 的数 
    else{
    	if(point>l)
		    num=point-l-1;
	    else
	        num=point-l;//负数 
	    cout<<str[l];
		if(l!=r)//要是只有一个数,就不用输出  . 
		    cout<<".";
	    for(int i=l+1;i<=r;i++){
		    if(str[i]!='.')//原来那个.不输出 
		        cout<<str[i];
     	}
     	if(num!=0)//阶数要是0 ,连E都不输出 
	        cout<<"E"<<num<<endl;	
	}
	return 0;
} 

 

标签:notation,Exponential,point,int,str,Output,Input,include,模拟
来源: https://blog.csdn.net/red_red_red/article/details/88426879