ACM (UVa) : 465


#include <stdio.h>
#include <stdlib.h>

int main ()
{
	long double x, y;
	char a [10000], b [10000], c;

	while ( scanf ("%s %c %s", a, &c, b) == 3) {
		x = atof (a);
		y = atof (b);
		printf("%s %c %s\n", a, c, b);

		if ( x > 2147483647 )
			printf("first number too big\n");
		if ( y > 2147483647 )
			printf("second number too big\n");
		if ( c == '+' ) {
			x = x + y;
			if ( x > 2147483647 )
			printf("result too big\n");
		}
		else {
			x = x * y;
			if ( x > 2147483647 )
			printf("result too big\n");
		}
	}
	return 0;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s