sorry i did some blunders
but finally got my code working :)

#include<iostream>
using namespace std;
void func(int a,int b,char *str)
{
    if(a==0&&b==0)
    {str[4-(a+b)]='\0';cout<<str<<"\n";return;}
    if(a>0)
    {
        str[4-(a+b)]='(';
        func(a-1,b,str);
    }
    if(b>a)
    {
        str[4-(a+b)]=')';
        func(a,b-1,str);
    }
}
int main()
{
    char str[10];
    func(2,2,str);
    return 0;
}


On Fri, Apr 15, 2011 at 8:44 PM, Harshit Gangal <[email protected]>wrote:

> there are two if statements and not an id else statement.
> so in first case a is modified and then next if statement is checked
> against b>a
> whereas in 2nd case a is not modified and checkd with the same value for
> the second if statement
>
>   On Fri, Apr 15, 2011 at 8:39 PM, priya mehta 
> <[email protected]>wrote:
>
>>  http://www.ideone.com/IKM57
>>
>> http://www.ideone.com/PmJ7A
>> there is a minor change between the codes
>> one works another doesn't
>> someone please tell the reason
>>
>> On Fri, Apr 15, 2011 at 8:38 PM, priya mehta <[email protected]>wrote:
>>
>>> http://www.ideone.com/PmJ7A
>>>
>>>
>>   --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
>  Harshit Gangal
> Fourth Year Undergraduate Student
> Dept. of Computer Science
> JIIT, Noida , India
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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

Reply via email to