bool foo(int x)

// Implement this function where 0 <= x <= 100
It should return true x% of times n false otherwise....

first i told him to have a static int s then increment it each time
the func is called...
and if  s % (100 - x ) == 0 then true else false.....

then he told me to have some different approach..

I told him like this:

bool foo(int x)
{
    // checking if x is btw 0 & 100

    if(x == 0)
              return false;
    if(x == 100)
              return true;

     srand(time(0));
     int rno = rand();

     if(rno % (100 - x) == 0)
            return True;
     else
           return False;
}

He was like okk but i think he was not completely satisfied....
Any other Approach...

-- 
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