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.
 
 
 

21 lines
247 B

  1. #include "jian.h"
  2. #include <limits>
  3. bool Sub(int a, int b, int *d)
  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. *d = a - b;
  12. return true;
  13. }
  14. }
  15. int sub(int a, int b)
  16. {
  17. return a - b;
  18. }