Pat 1073 PAT 1073. Scientific Notation (20)
来源:互联网 发布:elk 大数据平台 编辑:程序博客网 时间:2024/05/20 02:30
#include<iostream>
#include<cstdio>#include<sstream>
#include<string>
using namespace std;
int main()
{
string str,temp="";
getline(cin,str);
if(str[0]=='-')
{
temp+=str[0];
}
int indexE=str.find("E");
string num=str.substr(1,indexE-1);
char s=str[indexE+1];
stringstream ss; ///不要忘了此处的定义
string exp=str.substr(indexE+2,str.size()-indexE-2);//注意第二个参数是长度,表示从start位置起,截取length这么长的字符串
ss << exp; //注意此处的用法,,引入sstream头文件
int e;
ss>>e;
if(e==0)
{
temp+=num;
}
if(s=='+')
{
if(e<=num.size()-2)
{
temp+=num[0]+num.substr(2,e)+"."+num.substr(2+e,num.size()-2-e);
}
else
{
temp+=num[0]+num.substr(2,num.size()-2);
for(int i=0;i<e-num.size()+2;i++)temp+="0";
}
}
else
{
temp+="0.";
for(int i=0;i<e-1;i++)temp+="0";
temp+=num[0];
temp+=num.substr(2,num.size()-2);
}
cout<<temp<<endl;
return 0;
}
0 0
- Pat 1073 PAT 1073. Scientific Notation (20)
- PAT 1073. Scientific Notation (20)
- PAT 1073. Scientific Notation (20)
- PAT 1073. Scientific Notation (20)
- PAT 1073. Scientific Notation (20)
- PAT 1073. Scientific Notation(20)
- PAT 1073. Scientific Notation (20)
- PAT 1073. Scientific Notation (20)
- 【PAT】1073. Scientific Notation (20)
- PAT 1073. Scientific Notation
- PAT 1073. Scientific Notation
- 【PAT】1073. Scientific Notation
- pat 1073. Scientific Notation
- PAT 1073 Scientific Notation
- PAT (Advanced) 1073. Scientific Notation (20)
- PAT Advanced Level 1073. Scientific Notation (20)
- PAT A 1073. Scientific Notation (20)
- PAT甲级练习1073. Scientific Notation (20)
- linux脚本编程---sed流编辑器
- 页面跳转的集中方法
- 开发速度和代码质量,你的选择是?
- 各类正则表达式
- centos手动配置IP不显示日志
- Pat 1073 PAT 1073. Scientific Notation (20)
- NGUI 3.6.0以上版本 的研究五 :控件-常用到的脚本2
- 开源企业IM-免费企业即时通讯-恩布互联ENTBOOST 1.3版本发布
- HDU 4777 Rabbit Kingdom(树状数组)
- SVN命令使用详解
- 指向数组的指针&数组名和指针的区别
- 基站定位查询api使用接口
- Android 使用Aquery加载图片
- 流程管理在HSE中应用