UVA 465-Overflow
题目大意:与int型范围比较,判断第一个数,第二个数与结果是否太大
解题思路:用atof存double进行比较输出
#include <stdio.h>
#include <iostream>
#include <math.h>
#define max 2147483647
using namespace std;
int main() {
char a[10000], b[10000];
double m, n;
char c;
while(scanf("%s %c %s", a, &c, b) != EOF) {
printf("%s %c %s\n", a, c, b);
m = atof(a);
n = atof(b);
if(m > max)
printf("first number too big\n");
if(n > max)
printf("second number too big\n");
if(c == '+' && m + n > max)
printf("result too big\n");
else if(c == '*' && m * n > max)
printf("result too big\n");
}
return 0;
}