Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 0.24 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //exchange 2 variables without temp
  2.  
  3. void swap(int *a,int *b)
  4. {
  5.         *a = *a + *b;
  6.         *b = *a - *b;
  7.         *a = *a - *b;
  8. }
  9.  
  10. void swap2(int *a,int *b)
  11. {
  12.         *a ^= *b;
  13.         *b ^= *a;
  14.         *a ^= *b;
  15. }
  16.  
  17. //check 2 variables if equal
  18.  
  19. int equal(int a,int b)
  20. {
  21.         return !(a^b);
  22. }