UVA_465_Overflow

#include<iostream>    
#include<sstream>    
#include<string>    
#include<vector>    
#include<list>    
#include<set>    
#include<map>    
#include<stack>    
#include<queue>    
#include<algorithm>  
#include<bitset>
#pragma warning(disable:4996)    
using std::cin;
using std::cout;
using std::endl;
using std::stringstream;
using std::string;
using std::vector;
using std::list;
using std::pair;
using std::set;
using std::multiset;
using std::map;
using std::multimap;
using std::stack;
using std::queue;
using std::priority_queue;
using std::bitset;
int main()
{
	//freopen("input.txt", "r", stdin);    
	//freopen("output.txt", "w", stdout); 
	string str;
	while (getline(cin, str))
	{
		cout << str << endl;
		stringstream stream; stream << str;
		double value1, value2;char Operator;
		stream >> value1 >> Operator >> value2;
		if (value1 > 2147483647)
		{
			cout << "first number too big" << endl;
		}
		if (value2 > 2147483647)
		{
			cout << "second number too big" << endl;
		}
		if (Operator == '+')
		{
			if (value1 + value2 > 2147483647)
			{
				cout << "result too big" << endl;
			}
		}
		else
		{
			if (value1 * value2 > 2147483647)
			{
				cout << "result too big" << endl;
			}
		}
	}
	return 0;
}

你可能感兴趣的:(uva)