p465.cpp 936 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <algorithm>
  2. #include <array>
  3. #include <iostream>
  4. #include <map>
  5. #include <utility>
  6. #include <vector>
  7. #include <iomanip>
  8. #include <sstream>
  9. #include <climits>
  10. using namespace std;
  11. int main()
  12. {
  13. double left, right, result;
  14. string left_s, right_s;
  15. char operation;
  16. while(cin >> left_s >> operation >> right_s)
  17. {
  18. cout << left_s << " " << operation << " " << right_s << endl;
  19. stringstream ss;
  20. ss << left_s << " " << right_s;
  21. ss >> left >> right;
  22. if(left > INT_MAX)
  23. {
  24. cout << "first number too big" << endl;
  25. }
  26. if(right > INT_MAX)
  27. {
  28. cout << "second number too big" << endl;
  29. }
  30. if(operation == '+')
  31. result = left + right;
  32. else
  33. result = left * right;
  34. if(result > INT_MAX)
  35. {
  36. cout << "result too big" << endl;
  37. }
  38. }
  39. return 0;
  40. }