Start New Discussion Reply to this Discussion Number decomposition
Good day,
My Data Structure teacher asked me to do a list of exercises, and one of the questions consists of writing a program to solve the numbers decomposition problem, for example:
If the user types the number 5:
5
4 + 1
3 + 2
3 + 1 + 1
2 + 2 + 1
2 + 1 + 1 + 1
1 + 1 + 1 + 1 + 1
I need to use the list data structure to do that, anyway my problem isn't with the data structure, my problem is with the algorithm. Does anyone know a simple way to do this?
Regards.
10 Months Ago
Last Updated
Related Article: Boyce-Codd Normal Form (BCNF) Decomposition
is a Computer Science discussion thread by thompsonSensibl that has 1 reply, was last updated 1 year ago and has been tagged with the keywords: bcnf, boyce-codd, decomposition, normal, form.
modesto916
Light Poster
30 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
There is a pattern. The first column is initially the entered number (5), subtracted by 1. Hence you have 4 in the first column. The difference between the first number and the initial number is 1, since 5 - 4 = 1. The first number is again decreased by 1, resulting in 3. 5 - 3 = 2. 2 by itself can be expressed by 1 + 1, that'S why the 3rd row has 3 + 1 + 1. I think you can take it from there.
MonsieurPointer
Junior Poster
143 posts since Jun 2011
Reputation Points: 45
Solved Threads: 15
Skill Endorsements: 0
© 2013 DaniWeb® LLC
Page rendered in 0.0734 seconds
using 2.67MB