First verdict date: 2011-07-23
Last verdict date: 2017-01-08
Run Time: 0.000
Ranking (as of 2017-01-14): 1144 out of 3584
Language: C++
/*
UVa 465 - Overflow
To build using Visucal Studio 2008:
cl -EHsc -O2 overflow.cpp
*/
#include <iostream>
#include <string>
#include <sstream>
#include <limits>
using namespace std;
int main()
{
string line;
while (getline(cin, line)) {
istringstream iss(line);
double i, j;
char op;
iss >> i >> op >> j;
double result = (op == '+') ? i + j : i * j;
cout << line << endl;
if (i > numeric_limits<int>::max())
cout << "first number too big\n";
if (j > numeric_limits<int>::max())
cout << "second number too big\n";
if (result > numeric_limits<int>::max())
cout << "result too big\n";
}
return 0;
}
No comments:
Post a Comment