UVA 465- Overflow(借助atof函数将字符串改为double型)
2014-12-09 23:52
441 查看
Overflow
Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld
& %llu
Submit Status
Description
Write a program that reads an expression consisting of two non-negative integer and an operator. Determine if either integer or the result of the expression is too large to be represented as a ``normal'' signed
integer (type integer if you are working Pascal, type int if you are working in C).
too big''.
这个是问哪个值超了int类型 int类型的正整数范围为2^31
Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld
& %llu
Submit Status
Description
Overflow |
integer (type integer if you are working Pascal, type int if you are working in C).
Input
An unspecified number of lines. Each line will contain an integer, one of the two operators + or *, and another integer.Output
For each line of input, print the input followed by 0-3 lines containing as many of these three messages as are appropriate: ``first number too big'', ``second number too big'', ``resulttoo big''.
Sample Input
300 + 3 9999999999999999999999 + 11
Sample Output
300 + 3 9999999999999999999999 + 11
first number too big
result too big
这个是问哪个值超了int类型 int类型的正整数范围为2^31
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> #define inf 2147483647 char a[1010]; char b[1010]; int main() { char str; double n,m; while(~scanf("%s %c %s",a,&str,b)) { n=atof(a); m=atof(b); printf("%s %c %s\n",a,str,b); if(n>inf) printf("first number too big\n"); if(m>inf) printf("second number too big\n"); if(str=='+'&&n+m>inf) printf("result too big\n"); if(str=='*'&&n*m>inf) printf("result too big\n"); } return 0; }
相关文章推荐
- uva 465 Overflow(借助double型进行比较)
- UVA 465 - Overflow (浮点数的优势)
- Uva 465 - Overflow
- UVA 465 - Overflow
- uva-465-Overflow
- uva 465 - Overflow
- Uva 465 - Overflow
- uva465 - Overflow
- UVA 465 Overflow
- uva 465 - Overflow
- UVa 465 - Overflow 解题报告
- UVa 465 Overflow
- UVA 465 Overflow 高精度加法乘法(误!。其实应该说是浮点数的优势。。。)
- UVa 465 - Overflow
- UVa465 Overflow
- UVa 465 - Overflow
- UVA 465 - Overflow(大数)
- UVa 465 Overflow
- UVa 465 Overflow (比较大小难道不应该用double吗)
- uva 465 overflow