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 ...
随机推荐
- NEU OJ 1649 GMZ’s Pretty Number
先来一次线性素数筛,把1到10000000的素数都筛选出来,然后暴力跑一遍所有可能的值,打个表,查询的时候o(1)效率出解. #include<cstdio> #include<cs ...
- H5页面适配所有iPhone和安卓机型的六个技巧
http://www.th7.cn/web/html-css/201605/166006.shtml http://www.th7.cn/web/html-css/201601/153127.shtm ...
- A框架 第二部 实例化接收到的get类,调用父类抽象方法,自动执行方法call_user_func_array()
01父类抽象类 abstract.php <?phpabstract class controller_abstract{ protected $app; function __construc ...
- flex、As 3.0 小知识
<s:CheckBox id="checkBox" x="10" y="5" label="{new ObjectProx ...
- mysql 常用命令集锦[绝对精华]
一.连接MYSQL. 格式: mysql -h主机地址 -u用户名 -p用户密码 1.连接到本机上的MYSQL. 首先打开DOS窗口,然后进入目录mysql\bin,再键入命令mysql -u roo ...
- Qt Quick里的图形效果:阴影(Drop Shadow)
Qt Quick提供了两种阴影效果: DropShow,阴影.这个元素会根据源图像,产生一个彩色的.模糊的新图像,把这个新图像放在源图像后面,给人一种源图像从背景上凸出来的效果. InnerShado ...
- js-call、apply
这里主要就是做一些前人的总结,有时候会有自己的看法,首先把定义说一下 1.方法定义 call方法: 语法:call([thisObj[,arg1[, arg2[, [,.argN]]]]]) 定义 ...
- NDK编译应用程序
Android源码目录下的build/envsetup.sh文件,描述编译的命令 - m: Makes from the top of the tree. - mm: Build ...
- linq any() all() 返回true 或者false
一.any()只要有一个符合条件就返回true static void Main(string[] args) { //any 有符合条件的就返回true ,,,,,,,,,}; ); Console ...
- js操作select和option
1.动态创建select function createSelect(){ var mySelect = document.createElement_x("select"); m ...