fork download
  1. #include <stdio.h>
  2.  
  3. int is_equal( int a, int b)
  4. {
  5. return (((a - b) | (b - a))>>0) + 1;
  6. }
  7. int bitShift( int a, int b, int c)
  8. {
  9. return ((a - b) | (b - a))>>c ;
  10. }
  11. int main(void) {
  12. // your code goes here
  13. printf("%d\n",is_equal(7,7));
  14. printf("%d\n",is_equal(13,7));
  15.  
  16. printf("\n");
  17.  
  18. printf("0x%x\n",bitShift(1,2,0));
  19. printf("0x%x\n",bitShift(1,2,1));
  20. printf("0x%x\n",bitShift(1,2,31));
  21.  
  22.  
  23.  
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 2156KB
stdin
Standard input is empty
stdout
1
-1

0xffffffff
0xffffffff
0xffffffff