1073 Scientific Notation
题意:
给出科学计数法的形式,转化成常规的表示,要求保留所有的有效位数
思路:纯粹的字符串处理问题,注意边界条件即可。如+1.23E+02这种,转化后是123,既不需要补0,也不需要添加小数点。
代码:
#include <iostream>
#include <string>
using namespace std;
string change(string str)
{
string ans,sign;
]=='-') sign="-";
str.erase(str.begin());
int pos=str.find("E");
,str.size()--pos);
str=str.substr(,pos);
int exp=stoi(strExp);
pos=str.find(".");
str.erase(pos,);
){//前面添0
ans=,')+str;
}else{//后面补0
;//小数点后面的位数
');
else if(len>exp) {
ans=str;
ans.insert(exp+,".");
}else{
ans=str;
}
}
return sign+ans;
}
int main()
{
string str;
cin>>str;
cout<<change(str);
;
}
1073 Scientific Notation的更多相关文章
- PAT 1073 Scientific Notation
1073 Scientific Notation (20 分) Scientific notation is the way that scientists easily handle very ...
- 1073 Scientific Notation (20 分)
1073 Scientific Notation (20 分) Scientific notation is the way that scientists easily handle very la ...
- PAT 1073 Scientific Notation[字符串处理][科学记数法]
1073 Scientific Notation(20 分) Scientific notation is the way that scientists easily handle very lar ...
- PAT 甲级 1073 Scientific Notation (20 分) (根据科学计数法写出数)
1073 Scientific Notation (20 分) Scientific notation is the way that scientists easily handle very ...
- 1073. Scientific Notation (20)
题目如下: Scientific notation is the way that scientists easily handle very large numbers or very small ...
- PAT Advanced 1073 Scientific Notation (20 分)
Scientific notation is the way that scientists easily handle very large numbers or very small number ...
- PAT Basic 1024 科学计数法 (20 分) Advanced 1073 Scientific Notation (20 分)
科学计数法是科学家用来表示很大或很小的数字的一种方便的方法,其满足正则表达式 [+-][1-9].[0-9]+E[+-][0-9]+,即数字的整数部分只有 1 位,小数部分至少有 1 位,该数字及其指 ...
- PAT甲级——1073 Scientific Notation (20分)
Scientific notation is the way that scientists easily handle very large numbers or very small number ...
- PAT (Advanced Level) 1073. Scientific Notation (20)
简单模拟题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...
- PAT甲题题解-1073. Scientific Notation (20)-字符串处理
题意:给出科学计数法的格式的数字A,要求输出普通数字表示法,所有有效位都被保留,包括末尾的0. 分两种情况,一种E+,一种E-.具体情况具体分析╮(╯_╰)╭ #include <iostrea ...
随机推荐
- 利用大数据技术处理海量GPS数据
我秀中国物联网地图服务平台目前接入的监控车辆近百万辆,每天采集GPS数据7亿多条,产生日志文件70GB,使用传统的数据处理方式非常耗时. 比如,仅仅对GPS做一些简单的统计分析,程序就需要几个小时才能 ...
- 在一个web 应用中,改变url无非是2种方式,一种是利用超链接进行跳转,另一种是使用浏览器的前进和回退功能
在一个web 应用中,改变url无非是2种方式,一种是利用超链接进行跳转,另一种是使用浏览器的前进和回退功能 https://www.jianshu.com/p/27ee7df4ccc1
- Python中threading模块的join函数
Join的作用是阻塞进程直到线程执行完毕.通用的做法是我们启动一批线程,最后join这些线程结束,例如: for i in range(10): t = ThreadTest(i) thread_ar ...
- iOS自动化探索(二)WDA API的使用
前面我们已经安装好了WebdriverAgent, 现在可以用Facebook官方提供的API来进行一些操作 WDA API官方页面: https://github.com/facebook/WebD ...
- L128
How Google Search Results Work Political leanings don't factor into Google's search algorithm. But t ...
- Java并发编程之CountDownLatch
一.场景描述 在多线程程序设计中,经常会遇到一个线程等待一个或多个线程的场景 例如:百米赛跑,十名运动员同时起跑,由于速度的快慢,肯定有先到达和后到达的,而终点有个统计成绩的仪器,当所有选手到达终点时 ...
- Arcgis for Js之featurelayer实现空间查询和属性查询
空间查询和属性查询是常用的两种对数据的检索与查询方式,在本节,将讲述Arcgis for Js下如何实现featurelayer的这两种查询方式,先贴图给大家看看: 实现界面 属性查询 空间查询 看完 ...
- MySQL 的中文乱码问题终结
中文正确 1:保存sql脚本文件 utf8 !!!!! ANSI<-->GBK 2:打开mysql窗口 SET NAMES UTF8; 每次新打开窗口执行指令 3:SOURCE d:/1. ...
- VC++6.0/MFC中如何限制Edit控件输入 例子,只能输入0和1
1.Insert -> New Class -> 在Base Class中选择CEdit,在Name中输入CMyEdit. 2.在左边的ClassView中,右键击CMyEdit,选择Ad ...
- 【英语】Bingo口语笔记(86) - stand系列