i think it will work...

#include<stdio.h>
unsigned getNextBigger(unsigned a) {
   /* works for any word length */
 unsigned c = (a & -a);
 unsigned r = a+c;
  return ((((r ^ a) >> 2) / c) | r);}
int getNextSmaller(int num) {
    return ~getNextBigger(~num);}

int main(){
   unsigned int res , min;
   res = getNextBigger(12);
   printf("max = %d" , res);
   min = getNextSmaller(12);
   printf("min = %d" , min);
   return 0;}






Regards

Shivam

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to