Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- unsigned substract(unsigned a, unsigned b) {
- while (b) {
- unsigned borrow = ~a & b;
- unsigned diff = a ^ b;
- borrow <<= 1;
- a = diff;
- b = borrow;
- }
- return a;
- }
- int main(void) {
- unsigned a, b, diff;
- scanf("%u", &a);
- scanf("%u", &b);
- diff = substract(a, b);
- printf("%u-%u=%u\n", a, b, diff);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement