Overflow 

Write a program that reads an expression consisting of twonon-negative integer and an operator. Determine if either integer orthe result of the expression is too large to be represented as a``normal'' signed integer (typeinteger if you are workingPascal, type int if you are working in C).

Input

An unspecified number of lines. Each line will contain an integer, oneof the two operators+ or *, and another integer.

Output

For each line of input, print the input followed by 0-3 linescontaining as many of these three messages as are appropriate: ``firstnumber too big'', ``second number too big'', ``result too big''.

Sample Input

300 + 3
9999999999999999999999 + 11

Sample Output

300 + 3
9999999999999999999999 + 11
first number too big
result too big

题意:输入num1 + 或 * num2

若num1大于int可表示的最大值, 那么输出"first number too big"

同理num2的话, 输出"second number too big"

最后还要判定结果是否溢出, 若溢出, 输出"result too big"

都没溢出, 那么就没输出~

AC代码:

#include<stdio.h>
#include<stdlib.h> #define MAX 2147483647 int main() {
char num1[600], num2[600];
char ch;
double n1, n2;
while(scanf("%s %c %s", num1, &ch, num2) != EOF) {
printf("%s %c %s\n", num1, ch, num2);
n1 = atof(num1);
n2 = atof(num2);
if(n1 > MAX)
printf("first number too big\n");
if(n2 > MAX)
printf("second number too big\n");
if(ch == '+' && n1+n2 > MAX)
printf("result too big\n");
if(ch == '*' && n1*n2 > MAX)
printf("result too big\n");
}
return 0;
}

UVA 465 (13.08.02)的更多相关文章

  1. UVA 10494 (13.08.02)

    点此连接到UVA10494 思路: 采取一种, 边取余边取整的方法, 让这题变的简单许多~ AC代码: #include<stdio.h> #include<string.h> ...

  2. UVA 424 (13.08.02)

     Integer Inquiry  One of the first users of BIT's new supercomputer was Chip Diller. Heextended his ...

  3. UVA 10106 (13.08.02)

     Product  The Problem The problem is to multiply two integers X, Y. (0<=X,Y<10250) The Input T ...

  4. UVA 10194 (13.08.05)

    :W Problem A: Football (aka Soccer)  The Problem Football the most popular sport in the world (ameri ...

  5. UVA 253 (13.08.06)

     Cube painting  We have a machine for painting cubes. It is supplied withthree different colors: blu ...

  6. UVA 573 (13.08.06)

     The Snail  A snail is at the bottom of a 6-foot well and wants to climb to the top.The snail can cl ...

  7. UVA 10499 (13.08.06)

    Problem H The Land of Justice Input: standard input Output: standard output Time Limit: 4 seconds In ...

  8. UVA 10025 (13.08.06)

     The ? 1 ? 2 ? ... ? n = k problem  Theproblem Given the following formula, one can set operators '+ ...

  9. UVA 536 (13.08.17)

     Tree Recovery  Little Valentine liked playing with binary trees very much. Her favoritegame was con ...

随机推荐

  1. html-----005

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. CSS Margin(外边距)

    CSS Margin(外边距)属性定义元素周围的空间. Margin margin清除周围的元素(外边框)的区域.margin没有背景颜色,是完全透明的 margin可以单独改变元素的上,下,左,右边 ...

  3. [Introduction to programming in Java 笔记] 1.3.9 Factoring integers 素因子分解

    素数 A prime is an integer greater than one whose only positive divisors are one and itself.整数的素因子分解是乘 ...

  4. 搭建VPN服务器之PPTP

    搭建VPN服务器之PPTP 1. 查看系统是否支持PPP 一般自己的系统支持,VPS需要验证. [root@oldboyedu ~]# cat /dev/ppp cat: /dev/ppp: No s ...

  5. 零售POS开发

    零售POS系统是一款基于离线与在线两种模式的POS系统,能够将门店的销售数据及时准确的同步到企业服务器.离线模式操作更加快捷.稳定.高效:在线操作实时同步会员信息.查看库存.下载最新档案.公文公告等一 ...

  6. SQL Server 2008启用sa账户

    步骤一:首先,以window身份验证的方式登录到数据库. 步骤二:按照下图所示操作. 步骤三:在登录名sa上右击鼠标,选择属性.打开属性对话框. 步骤四:填写sa账户密码 步骤五:点击左边菜单状态,如 ...

  7. Apache 支持.htaccess

    ******************************************************************************* Apache 服务器 ********* ...

  8. about Red_Hat_Enterprise_Linux_7

    systemd systemd 是 Linux 的系统和服务管理程序,替换了 Red Hat Enterprise Linux 之前的发行本中使用的 SysV.systemd 与 SysV 和 Lin ...

  9. 【转】深入 char * ,char ** ,char a[ ] ,char *a[] 内核

    原文出处:http://blog.csdn.net/daiyutage/article/details/8604720    C语言中由于指针的灵活性,导致指针能代替数组使用,或者混合使用,这些导致了 ...

  10. (三大框架SSH)面试题锦集

    http://www.cnblogs.com/dieyf/p/4109233.html