uva 465 Overflow

#include<iostream>

#include<cctype>

#include<cstdlib>

#include<cstring>

#include<cstdio>

using namespace std;



const int MIN = -1u >> 1;



int main(){

    double a,b;

    char s1[1000],s2[1000];

    char c;

    while((scanf("%s %c %s",s1,&c,s2))!=EOF){

        printf("%s %c %s\n",s1,c,s2);

        a = atof(s1);

        b = atof(s2);

        if(a > MIN) printf("first number too big\n");

        if(b > MIN) printf("second number too big\n");

        if(c=='+'&&a+b>MIN)printf("result too big\n");

        if(c=='*'&&a*b>MIN)printf("result too big\n");

    }



    return 0;

}

 

你可能感兴趣的:(overflow)