You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 line
223 B

  1. #include "jia.h"
  2. #include <limits>
  3. bool Add(int a, int b, int *c)
  4. {
  5. if ((a > 0 && b > 0 && a > (INT_MAX - b)) || (a < 0 && b < 0 && a < (INT_MIN - b)))
  6. {
  7. return false;
  8. }
  9. else
  10. {
  11. *c = a + b;
  12. return true;
  13. }
  14. }