uva465 - Overflow
来源:互联网 发布:js 变量的长度 编辑:程序博客网 时间:2024/05/16 13:00
uva465 - Overflow
题目大意:检查两个数相加相乘会不会溢出
解题思路:atof直接把字符串读成浮点数,然后浮点数的范围比int的大的多,直接比较就行了。
#include<cstdio>#include<cstdlib>#include<cstring>char str1[10000];char str2[10000];char op;int limit=2147483647;int main(){ double a,b; while((scanf("%s %c %s",str1,&op,str2))!=EOF) { a=atof(str1); b=atof(str2); printf("%s %c %s\n",str1,op,str2); if(a>limit)printf("first number too big\n"); if(b>limit)printf("second number too big\n"); if(op=='+') if(a+b>limit)printf("result too big\n"); if(op=='*') if(a*b>limit)printf("result too big\n"); memset(str2,0,sizeof(str2)); memset(str1,0,sizeof(str1)); } return 0;}
0 0
- uva465 - Overflow
- uva465 overflow
- UVa465 Overflow
- uva465 - Overflow
- uva465 overflow
- uva465 - Overflow
- UVA465 - Overflow
- 高精度 UVA465 Overflow
- uva465
- UVA465
- UVA465
- uva465
- uva465--BigNumber
- UVA465-溢出
- ACM->uva465
- uva465(伪高精度)
- overflow
- overflow
- Qt学习之路(60): 创建shared library
- Qt之保持GUI响应
- InstallShield Limited Edition for Visual Studio 2013 图文教程
- 动态代理实现数据库连接池功能(代理Connection的close方法)
- (第14讲)哈希表的开放地址法中的二次探测
- uva465 - Overflow
- PAT (Advanced Level) 1099 Build A Binary Search Tree (30)
- android音乐播放器开发在线加载歌词
- 基于Ubuntu交叉编译FFmpeg Windows SDK
- dialog属性参数
- [数学 高精度] HDU 5241 Friends
- Caused by: java.lang.OutOfMemoryError: PermGen space
- java实现潜艇大战游戏之Java swing图形界面开发游戏项目潜艇大战源码及实现方式详解
- iOS开发进阶