Click here to Skip to main content
15,892,298 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Recursion to normal way Pin
iNoor728-Jun-20 11:01
iNoor728-Jun-20 11:01 
GeneralRe: Recursion to normal way Pin
harold aptroot8-Jun-20 11:11
harold aptroot8-Jun-20 11:11 
GeneralRe: Recursion to normal way Pin
iNoor728-Jun-20 11:39
iNoor728-Jun-20 11:39 
GeneralRe: Recursion to normal way Pin
Dave Kreskowiak8-Jun-20 16:44
mveDave Kreskowiak8-Jun-20 16:44 
AnswerRe: Recursion to normal way Pin
kalberts8-Jun-20 10:38
kalberts8-Jun-20 10:38 
GeneralRe: Recursion to normal way Pin
iNoor728-Jun-20 11:03
iNoor728-Jun-20 11:03 
GeneralRe: Recursion to normal way Pin
Richard MacCutchan8-Jun-20 21:33
mveRichard MacCutchan8-Jun-20 21:33 
GeneralExercise Pin
kalberts8-Jun-20 22:31
kalberts8-Jun-20 22:31 
Trying to evade the problem that you don't understand recursion by rewriting it to non-recursion is never going to work.

In my university days, a fellow student realized that he did not fully master recursion - termination in particular. So he defined a small programming problem for himself. After solving the task, he never had any problems with how to terminate a recursion. I think he made an excellent "programming etude", and have spread it out to a lot of people. It goes like this:

When you enter the recursive function, you write a line with the number of spaces given by the recursion depth, and then an asterisk. When you leave the recursive function, you do the same. The top level call gives parameters for (a) the maximum recursion depth, which you dive right into, (b) an intermediate recursion depth that you return to, before again recursing to the maximum depth, and (c) the number of times to recurse to the maximum depth and back to the intermediate level, before finally returning to the top level call (i.e. the number of "peaks").

For a call with arguments (5, 3, 3) the ouput should look something like
C++
*
 *
  *
   *
    *
    *
   *
  *
   *
    *
    *
   *
  *
   *
    *
    *
   *
  *
 *
*
The problem statement seems very simple (and it is, for a seasoned recursionist). For an inexperienced programmer, you can usually hear a lot of cursing and re-cursing during the testing Smile | :)
GeneralRe: Exercise Pin
Richard MacCutchan8-Jun-20 22:34
mveRichard MacCutchan8-Jun-20 22:34 
JokeRe: Exercise Pin
Peter_in_27808-Jun-20 22:43
professionalPeter_in_27808-Jun-20 22:43 
GeneralRe: Exercise Pin
kalberts9-Jun-20 2:50
kalberts9-Jun-20 2:50 
GeneralRe: Exercise Pin
Richard MacCutchan9-Jun-20 3:39
mveRichard MacCutchan9-Jun-20 3:39 
GeneralRe: Exercise Pin
kalberts9-Jun-20 3:59
kalberts9-Jun-20 3:59 
GeneralRe: Exercise Pin
Richard MacCutchan9-Jun-20 4:11
mveRichard MacCutchan9-Jun-20 4:11 
GeneralRe: Exercise Pin
Richard MacCutchan9-Jun-20 4:29
mveRichard MacCutchan9-Jun-20 4:29 
GeneralRe: Exercise Pin
Richard MacCutchan9-Jun-20 20:56
mveRichard MacCutchan9-Jun-20 20:56 
GeneralRe: Exercise Pin
kalberts9-Jun-20 22:08
kalberts9-Jun-20 22:08 
GeneralRe: Exercise Pin
Richard MacCutchan9-Jun-20 23:33
mveRichard MacCutchan9-Jun-20 23:33 
QuestionIs there any opensource version of telnet client library(encrypted) available for windows Pin
Member 147721178-Jun-20 2:25
Member 147721178-Jun-20 2:25 
AnswerRe: Is there any opensource version of telnet client library(encrypted) available for windows Pin
Richard MacCutchan8-Jun-20 5:31
mveRichard MacCutchan8-Jun-20 5:31 
QuestionEfficient way to read/write file Pin
manoharbalu7-Jun-20 22:32
manoharbalu7-Jun-20 22:32 
AnswerRe: Efficient way to read/write file Pin
CPallini8-Jun-20 1:28
mveCPallini8-Jun-20 1:28 
AnswerRe: Efficient way to read/write file Pin
Greg Utas8-Jun-20 2:23
professionalGreg Utas8-Jun-20 2:23 
AnswerRe: Efficient way to read/write file Pin
kalberts8-Jun-20 4:32
kalberts8-Jun-20 4:32 
AnswerRe: Efficient way to read/write file Pin
Joe Woodbury8-Jun-20 14:24
professionalJoe Woodbury8-Jun-20 14:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.