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 ...
随机推荐
- angular一些常用的方法:
angular.copy(); 用法:对Object对象的深度拷贝$scope.data = {name:'yanjinyun',age:'11'}; $scope.origData = angula ...
- shell 数组操作
1. 定义数组: var_array=(one two three four five) 2.常用操作 获取数组长度: ${#var_array[@]} 获取所有数组元素: ${var_array[ ...
- Linux find grep用法示例
在linux下面工作,有些命令能够大大提高效率.本文就向大家介绍find.grep命令,他哥俩可以算是必会的linux命令,我几乎每天都要用到他们.本文结构如下: find命令 find命令的一般形式 ...
- JsonUtils
import net.sf.json.JSONObject; public class JsonTools { public static JSONObject getJSONObject(Strin ...
- 003——VUE操作元素属性
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 内存保护机制及绕过方法——利用未启用SafeSEH模块绕过SafeSEH
利用加载模块之外的地址绕过safeSEH 前言:文章涉及的概念在之前的文章中都有过详细的讲解 ⑴. 原理分析: 当程序加载进内存中后,处理PE文件(exe,dll),还有一些映射文件,safeSEH ...
- react table dropdown
<DropdownButton type="primary" trigger={['click']} onClick={() => this.detail(item)} ...
- Flask的配置文件
Flask的配置文件 与 session 配置文件 flask中的配置文件是一个flask.config.Config对象(继承字典) 默认配置为: { 'DEBUG': get_debug_flag ...
- Android 系统信息的获取
Android 系统信息的获取 一.内存(ram): 1.android 的内存大小信息存放在系统的 /proc/meminfo 文件里面,通过adb shell 进入 手机目录后,使用 cat /p ...
- HTML的后缀显示、标准格式和标签(1)
后缀的显示 win10:打开我的计算机--->点击上面的查看--->选中文件扩展名 win8:打开我的计算机--->点击上面的组织选中文件夹选项--->点击上面的查看---&g ...