# Any 1 can write a C cording for this problem plz post hear..

• 08-21-2007
cbuwa
Any 1 can write a C cording for this problem plz post hear..
A partition of a positive integer N is a sequence of positive integers that sum to N. c cording 4 non increasing partition of n....

Eg If n = 4

output like

4
3 1
2 2
2 1 1
1 1 1 1
• 08-21-2007
dwks
Is this homework? http://cboard.cprogramming.com/annou...t.php?f=4&a=39

Have you actually tried this? Do you have anything to show for it?

 A recursive function would work well for this, although I'm sure you could implement an iterative version as well. [/edit]
• 08-21-2007
cbuwa
Quote:

Originally Posted by dwks
Is this homework? http://cboard.cprogramming.com/annou...t.php?f=4&a=39

Have you actually tried this? Do you have anything to show for it?

 A recursive function would work well for this, although I'm sure you could implement an iterative version as well. [/edit]

No dat s nt home work...ill try to do it by using iterative manner bt no idea to do dat...

if any 1 cn gimme a psedocode dats more dan enough... den i cn get an idea of it...
• 08-21-2007
dwks
Typing proper english takes only a few more seconds of your time, if that, but it makes your post give a better impression, and might save your readers some time. Really. Try it sometime.

An iterative solution is probably possible, but it would be more complicated than a recursive solution. First of all, "iterative" means with loops, like for or while loops, which recursive is a function that calls itself. Recursion isn't as hard as it sounds.

I wrote up a recursive solution, but I deleted it because I wasn't sure if you wanted to see it or not . . . anyway, what it did was basically this:
Code:

```if max == 0:     print "\n"; else:     for x in (1..max):         print x;         recurs(max-x);```
Think about it. I think it would work, though I'm not sure my logic is sound or that I converted my code into pseudo-[python] correctly.
• 08-21-2007
cbuwa
its ok ill try....... ya i think recursive way is little bit easy to solve that problem....
• 08-21-2007
simpleid
let's not respond to people who type like that here... they should keep that crap in counter-strike.
• 08-21-2007
MacGyver
Quote:

Originally Posted by simpleid
let's not respond to people who type like that here... they should keep that crap in counter-strike.

wut u mean by dat? r u sayin only 1337 h4x0r skr1p7 k1dd13z talk lik dis? ;)

To the OP: http://catb.org/~esr/faqs/smart-questions.html