PAT 1073. Scientific Notation (20)
来源:互联网 发布:临沂seo网站推广 编辑:程序博客网 时间:2024/05/16 15:36
Scientific notation is the way that scientists easily handle very large numbers or very small numbers. The notation matches the regular expression [+-][1-9]"."[0-9]+E[+-][0-9]+ which means that the integer portion has exactly one digit, there is at least one digit in the fractional portion, and the number and its exponent's signs are always provided even when they are positive.
Now given a real number A in scientific notation, you are supposed to print A in the conventional notation while keeping all the significant figures.
Input Specification:
Each input file contains one test case. For each case, there is one line containing the real number A in scientific notation. The number is no more than 9999 bytes in length and the exponent's absolute value is no more than 9999.
Output Specification:
For each test case, print in one line the input number A in the conventional notation, with all the significant figures kept, including trailing zeros,
Sample Input 1:+1.23400E-03Sample Output 1:
0.00123400Sample Input 2:
-1.2E+10Sample Output 2:
-12000000000
//科学计数法,科学计数法可以处理非常大和非常小的数//这种题目主要特点比较繁琐#include <iostream>#include <cstdio>#include <string>#include <string.h>#include <string>using namespace std;char str[10000];int main(void){scanf("%s", str);//输入数字分为一般数和零int length = strlen(str);bool isPos = str[0] == '+' ? true : false;int i = 2;if (i < length)str[i] = str[i-1];while (i < length && str[i] != 'E')++i;bool exPos = str[i+1] == '+' ? true : false;int exp = 0;for (int j = i + 2; j < length; ++j)exp = exp * 10 + str[j] - '0';if (!isPos)printf("-");if (exPos){int j = 2;while (j < i && exp >= 0){printf("%c", str[j]);++j;--exp;}if (j < i){printf(".");while (j < i){printf("%c", str[j]);++j;}}while (exp >= 0){printf("0");--exp;}printf("\n");}else{printf("0.");while (exp > 1){printf("0");--exp;}int j = 2;while (j < i){printf("%c", str[j]);++j;}printf("\n");}return 0;}
- 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 PAT 1073. Scientific Notation (20)
- 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)
- PAT甲级1073. Scientific Notation (20)
- manacher算法
- 有关SCN的小结
- CentOS 6.5 下的基础操作
- 枚举 USB 复合设备
- quartz2D 图片剪切
- PAT 1073. Scientific Notation (20)
- 使用Mac终端编译Java代码时的乱码问题
- 浅析OpenGL
- 解决tomcat在页面传递过程中改变数据编码格式的问题
- C/C++ 参数载入问题
- UVA712 - S-Trees
- 电笔的工作原理
- 正则表达式--图表
- JavaScript DOM对象和JQuery对象相互转换