![]() |
|
#1
|
|||
|
|||
recursive algorithmi'm having a problem with below recursive code.
there are 4 chars stored in a array, 'a', 'b', 'c', 'd'. input is between 1 and 16, and output should look like this: when input is 1: a b c d when iput is 2: aa ab ac ad ba bb bc bd ca cb cc cd da db dc dd and so on... here is the code i'v been working with: CPP / C++ / C Code:
where should i change to make it work? |
|
#2
|
||||
|
||||
|
Welcome to GID and Kudo's for a first post and using CODE tags! Thank you!
Quote:
__________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#3
|
||||
|
||||
|
I think your problem occurs because everytime you call f, your redeclareing the array temp[]. So basically you place a into temp[x], then call f again. But since f declares a variable called temp[] a is then erased from temp[x] and garbage is in its place. just declare temp in main (or whatever function f is called from) and add it as a peramiter to f so f reads void f(int x, int num, char temp[]) That should help you some.
__________________
"To argue with a person who has renounced the use of reason is like administering medicine to the dead." -Thomas Paine www.sullivan-county.com/deism.htm |
Recent GIDBlog
I?m Home by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| shortest path algorithm and file saving | Pandiani | C++ Forum | 10 | 17-Jul-2006 11:46 |
| help.... SLR * algorithm | tay | C Programming Language | 4 | 10-Sep-2004 12:48 |
| algorithm for display complex graph | ctai010 | C++ Forum | 0 | 20-Mar-2004 06:24 |
| Speed up compare algorithm | captnsaj | C++ Forum | 4 | 04-Feb-2004 15:50 |
| Color scale algorithm | Ilya | C++ Forum | 0 | 28-Oct-2003 12:07 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The