ok question was different ....we have to find total number..

On Sat, Dec 31, 2011 at 2:08 PM, atul anand <atul.87fri...@gmail.com> wrote:

> here is solution for non-decreasing number using simple recursion.
>
> static int min=0;
> static int flag=0;
> int nonDec(int num)
> {
> if(num==0)
>  {
> return 0;
> }
>
> nonDec(num/10);
> if(flag==1)
> {
>  return -1; // not a non-decreasing number.
> }
> if(min <= (num%10))
>  {
> min=num%10;
> }
>  else
> {       flag=1;
> return -1;
>  }
>
> return 1; // is a non-decreasing number.
>
> }
>

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