What is the problem with sunny's solution ??

On Mon, Jun 20, 2011 at 9:31 AM, RAJAT kumar singh
<rajat123si...@gmail.com>wrote:

> #include<stdio.h>
> #include<math.h>
> char
> s[]={'a','x','x','b','a','b','x','x','x','x','x','a','b','a','x','x','b',};
>
>
> int minimum(char,char,int );
> int main()
> {
>
> int i=minimum('a','b',17);
> printf("%d",i);
> }
>
>
> int minimum(char a ,char b,int n)
> {
> int i=0;
> int lindex=-1,rindex=-1,min;
>
> min=n;
> while(i<n)
> {
>
>
>
>
> if(s[i]==a)
> {
> lindex=i;
> if(rindex!=-1)
> {
> min=mini(min,abs(lindex-rindex));
> }
> }
>
> else if(s[i]==b)
> {
> rindex=i;
> if(lindex!=-1)
> {
> min=mini(min,abs(lindex-rindex));
> }
>
>
>
> }
>
>
> i++;
> }
>
> return min;
> }
>
>
> int mini(int a,int b)
> {
>
> if(a>b)
> return b;
> else
> return a;
>
>
> }
>
> --
> 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.
>



-- 
Thanks and Regards ,
Gaurav Saxena

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