PAT 1073
来源:互联网 发布:网络直播视频 编辑:程序博客网 时间:2024/04/28 16:54
1073. Scientific Notation (20)
讲科学技术法转换成正常的数值表示法。
注意小数点在最后的情况即可,比如+1.2E+1,结果为12,而不是12.。
#include <string>#include <cstdio>#include <iostream>#include <algorithm>using namespace std;string linetonum(const string &line);int main(){ string line; cin >> line; cout << linetonum(line) << endl; return 0;}string linetonum(const string &line){ string exp(line, line.find('E')+1, line.length()), number(line, 1, line.find('E')-1); int numexp = atoi(exp.c_str()); if (numexp > 0) { while(numexp--) { size_t ppos(number.find('.')); if (ppos == string::npos) { number += '0'; } else { number[ppos] = number[ppos+1]; number[ppos+1] = '.'; if (number.find('.') == number.length() - 1) { number.erase(number.find('.')); } } } } else { while(numexp ++) { size_t ppos(number.find('.')); number[ppos] = number[0]; number[0] = '.'; number = "0" + number; } } if (line[0] == '-') { number = "-" + number; } return number;}
0 0
- PAT 1073
- pat 1073
- PAT 1073
- PAT 1073
- Pat 1073 PAT 1073. Scientific Notation (20)
- pat advanced 1073
- pat解题报告【1073】
- PAT 1073 Scientific Notation
- pat-advanced(1073-1076)
- PAT(甲级)1073
- 浙大PAT甲级 1073
- PAT甲级1073
- pat
- 【PAT】
- PAT
- PAT
- PAT
- PAT
- IE下Css圆角问题
- UILocalizedIndexedCollation 使用
- HTML中忽略的小问题
- 欧拉计划 第6题
- cocos2d-x 自定义精灵类
- PAT 1073
- 遠端存取SQL 2008 R2 Express方法
- 【linux学习笔记】sort|uniq | cut | wc (我的第一篇markdown笔记)
- 逐梦之路充满艰辛
- Nginx初识
- 常用正则表达式
- Dialect class not found: org.hibernate.dialect.Oracle10gDialect 报错解决
- 黑马程序员_Java基础总结
- pat 1025