ohh , the number can repeat itself. I dint notice that.

On Fri, Oct 28, 2011 at 4:02 PM, mohit verma <mohit89m...@gmail.com> wrote:

> something like this :
>
> for(int i=0;temp=sum , i<sum/2;i++)
> { temp=temp-i;
> for(int j=i+1;j<temp;j++)
>  cout<<i<<" "<<j<<" "<<temp-j<<"\n";
> }
>
> But there is a problem with code :
>      like for sum 7 , repeated cases are 0 3 4 and 0 4 3.
>
> On Thu, Oct 27, 2011 at 7:46 PM, rj7 <r4ra...@gmail.com> wrote:
>
>> @Nitin Garg well if negatives are included there would be infinite
>> number of solutions
>> right?
>>
>> and we can start we start with dividing the sum by combinations.
>> Atleast one number must be greater than sum/combination..
>> Am not sure it this is same as that subset manipulation...
>> pls post the algo for that recursion method!
>>
>> On Oct 27, 12:21 am, Nitin Garg <nitin.garg.i...@gmail.com> wrote:
>> > Are we talking about only positive integers here?
>> >
>> > On Wed, Oct 26, 2011 at 11:33 PM, Vaibhav Mittal
>> > <vaibhavmitta...@gmail.com>wrote:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > +1 Prem
>> > > @ligerdave : I knew about the recursion method..but can u throw some
>> light
>> > > on the pointer based method..(with a small example maybe)..
>> > > Specifically I wanted to know the implementation part and the running
>> time
>> > > of the algorithm.
>> >
>> > > On Wed, Oct 26, 2011 at 8:33 PM, ligerdave <david.c...@gmail.com>
>> wrote:
>> >
>> > >> @meng You already have the pattern figured out. each time subtract 1
>> > >> from the lowest digit and add to higher digit(only once), until the
>> > >> lowest digit equals to closest higher digit. the selection of which
>> > >> number to start could be figured out with given parameters sum and
>> > >> combination
>> >
>> > >> @Prem, no recursion needed here. it make it more complex than
>> > >> necessary. one loop with a pointer should be able to resolve this
>> >
>> > >> On Oct 24, 6:28 pm, Meng Yan <mengyan.fu...@gmail.com> wrote:
>> > >> > Hi, my question is
>> >
>> > >> > given sum=N and combination constraint=M (the number of elements),
>> how
>> > >> to
>> > >> > find all possible combinations of integers?
>> >
>> > >> > For example, given sum=6, combination=3; how to get the result as
>> > >> following:
>> > >> > 1+1+4;
>> > >> > 1+2+3;
>> > >> > 2+2+2;
>> >
>> > >> > We don't care about order of the elements, which means 1+1+4 and
>> 1+4+1
>> > >> are
>> > >> > considered as same combination.
>> >
>> > >> > Thanks a lot!
>> >
>> > >> > Meng
>> >
>> > >> --
>> > >> 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.
>> >
>> > >  --
>> > > 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.
>> >
>> > --
>> > Nitin Garg
>> >
>> > "Personality can open doors, but only Character can keep them open"
>>
>> --
>> 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.
>>
>>
>
>
> --
> ........................
> *MOHIT VERMA*
>
>


-- 
........................
*MOHIT VERMA*

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