UVa 465 Overflow: Is the size of a double?

Source: Internet
Author: User

465-overflow

Time limit:3.000 seconds

Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=97&page=show_problem &problem=406

Write a program so reads an expression consisting of two non-negative integer and a operator. Determine if either integer or the result of the expression was too large to be represented as a ' normal ' signed integer (Type integer If you are are working Pascal, type int If you are working in C).

Input

An unspecified number of lines. Each line would 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 to these three messages as are Appropriat E: ' Number too big ', ' second number too ', ' result too big '.

Sample Input

300 + 3
9999999999999999999999 + 11

Sample Output

300 + 3
9999999999999999999999 + 11
Number Too big
Result too big

As described in the title.

Complete code:

/*0.019s*/
    
#include <cstdio>  
const double maxint = -1u >> 1;  
    
Char str[600];  
    
int main ()  
{  
    double A, b;  
    char op;  
    while (gets (str))  
    {  
        puts (str);  
        SSCANF (str, "%lf%c%lf", &a, &op, &b);  
        if (a > Maxint) puts ("number too big");  
        if (b > Maxint) puts ("second number too big");  
        if (op = = ' + ' && A + B > Maxint | | | op = = ' * ' && A * b > Maxint) puts ("result too big");  
    } return  
    0;  
}

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.