465 - Overflow

来源:互联网 发布:淘宝模板化设置 编辑:程序博客网 时间:2024/06/06 07:22
#include <stdio.h>#include <stdlib.h>#include <limits.h>char num1[300],num2[300];int main( int argc, char * argv[] ) {char c;while( scanf( "%s %c %s", num1, &c, num2 ) != EOF ) {printf( "%s %c %s\n", num1, c, num2 );double a, b;a = atof( num1 );b = atof( num2 );if( a > INT_MAX ) printf( "first number too big\n" );if( b > INT_MAX ) printf( "second number too big\n" );if( c == '+' && a + b > INT_MAX ) printf( "result too big\n" );if( c == '*' && a * b > INT_MAX ) printf( "result too big\n" );}return 0;}

0 0