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.
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.
Print the only line — the "simple exponential notation" of the given number x.
16
1.6E1
01.23400
1.234
.100
1E-1
100.
1E2
分析:这种题要多注意细节!
代码:
#include <bits/stdc++.h>
using namespace std;
int n,m,cnt,len,l,r,now;
string a,ans;
int main()
{
int i,j,k,t;
cin>>a;
len=a.length();
//找小数点;
for(now=;now<len&&a[now]!='.';now++);
//找左端点和右端点;
if(a[l]=='.')l++;if(a[r]=='.')r--;
for(l=;a[l]=='';l++);
if(a[l]=='.')for(l++;a[l]=='';l++);
for(r=len-;a[r]=='';r--);
if(a[r]=='.')for(r--;a[r]=='';r--); ans+=a[l];
if(r!=l){
ans+='.';
for(i=l+;i<=r;i++)if(a[i]!='.')ans+=a[i];
}
cnt=now-(l+);
if(l+>now)cnt++;
cout<<ans;
if(cnt)cout<<"E"<<cnt;
cout<<endl;
//system("pause");
return ;
}
Exponential notation的更多相关文章
- Educational Codeforces Round 14 C. Exponential notation 数字转科学计数法
C. Exponential notation 题目连接: http://www.codeforces.com/contest/691/problem/C Description You are gi ...
- Codeforces 691C. Exponential notation 模拟题
C. Exponential notation time limit per test: 2 seconds memory limit per test:256 megabytes input: st ...
- codeforces 691C C. Exponential notation(科学计数法)
题目链接: C. Exponential notation time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- CF-697B Barnicle与691C Exponential notation
无聊写两个题解吧,上午做比赛拉的,感触很多! B. Barnicle time limit per test 1 second memory limit per test 256 megabytes ...
- 【模拟】Codeforces 691C Exponential notation
题目链接: http://codeforces.com/problemset/problem/691/C 题目大意: 输入一个数,把它表示成a·10b形式(aEb).输出aEb,1<=a< ...
- Codeforces 691C. Exponential notation
题目链接:http://codeforces.com/problemset/problem/691/C 题意: 给你一个浮点数,让你把这个数转化为 aEb 的形式,含义为 a * 10b, 其中 a ...
- D3中动画(transition函数)的使用
关于transition的几个基本点: 1. transition()是针对与每个DOM element的,每个DOM element的transition并不会影响其他DOM element的tra ...
- jQuery静态方法isFunction,isArray,isWindow,isNumeric使用和源码分析
上一篇随笔中总结了js数据类型检测的几个方法和jQuery的工具方法type方法,本篇要分析几个方法都依赖type方法,所以不了解type方法的请先参看http://www.cnblogs.com/y ...
- [Linux-shell] AWK
Go to the first, previous, next, last section, table of contents. Printing Output One of the most co ...
随机推荐
- FZU 1502 Letter Deletion
最长公共子序列. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #i ...
- javascript 如何正确使用getElementById,getElementsByName(), and getElementsByTagName()
WEB标准下可以通过getElementById(), getElementsByName(), and getElementsByTagName()访问DOCUMENT中的任一个标签. (1)get ...
- WINDOWS特有的消息常量标识符
'========================================'WINDOWS特有的消息常量标识符'======================================== ...
- linux设置时间服务器
对多个linux服务器,时间保持一致是很必要的.根据精确度要求,应该有相应的时间间隔进行时间同步.如果不进行时间同步,时间久了就会差别很大,遇到问题时定位就很困难.因为多台设备的配合,log之间可能有 ...
- ASP.NET ValidationGroup 属性和CssClass 属性
定义和用法 获取或设置在 Button 控件回发到服务器时要进行验证的控件组. 通常在表单中存在多个按钮时使用该属性. 语法 <asp:Button ValidationGroup=" ...
- 《JS权威指南学习总结--4.9.3in和instanceof运算符》
内容要点: 一.in运算符 in运算符希望它的左操作数是一个字符串或可以转换为字符串,希望它的右操作数是一个对象.如果右侧的对象拥有一个名为左操作数数值的属性名,那么表达式返回true. 例如: va ...
- hdu_5748_Bellovin(LIS)
题目链接:hdu_5748_Bellovin 题意: 给你一个数列ai,设f(a1,a2,a3,..an)=(f1,f2,f3,...,fn),其中fi表示以ai结尾的最长递增子序列长度,注意:必须要 ...
- hdu_4718_The LCIS on the Tree(树链剖分+线段树合并)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4718 题意:给你一棵树,每个节点有一个值,然后任给树上的两点,问这两点的最长连续递增区间是多少 题解: ...
- lua学习
在lua中,一切都是变量,除了关键字. 1.注释: 单行注释: 连续两个减号“--”表示注释的开始,一直延续到行末.相当于C语言中的“//” 多行注释:由“--[[”表示注释开始, “]]”表示注释结 ...
- how to use tar?
In UNIX, tar is the most useful tool to compress files (just like zip in Windows.) To compress, inpu ...