Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdint.h>
  3.  
  4. uint16_t satsum(uint16_t x, uint16_t y) {
  5. if (x < y) {
  6. uint16_t t = x;
  7. x = y;
  8. y = t;
  9. }
  10.  
  11. uint16_t res = x + y;
  12.  
  13. if (res < x) {
  14. return (x - res - 1 + y );
  15. }
  16.  
  17. return res;
  18. }
  19.  
  20. int main() {
  21. uint16_t r = satsum((uint16_t )65515,(uint16_t )10);
  22. printf("%i", (int)r);
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement