Click here to Skip to main content
15,921,774 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHelp me - C++ Pin
Coder1122334416-Jun-20 4:05
Coder1122334416-Jun-20 4:05 
AnswerRe: Help me - C++ Pin
CPallini16-Jun-20 4:47
mveCPallini16-Jun-20 4:47 
AnswerRe: Help me - C++ Pin
Richard MacCutchan16-Jun-20 5:05
mveRichard MacCutchan16-Jun-20 5:05 
AnswerRe: Help me - C++ Pin
ZurdoDev16-Jun-20 5:26
professionalZurdoDev16-Jun-20 5:26 
GeneralRe: Help me - C++ Pin
kalberts16-Jun-20 5:49
kalberts16-Jun-20 5:49 
AnswerRe: Help me - C++ Pin
kalberts16-Jun-20 5:36
kalberts16-Jun-20 5:36 
GeneralRe: Help me - C++ Pin
Richard MacCutchan16-Jun-20 6:06
mveRichard MacCutchan16-Jun-20 6:06 
QuestionVisual Studio and Windows SDKs - need some experienced comments about SDK usage and RTLs Pin
charlieg11-Jun-20 12:44
charlieg11-Jun-20 12:44 
AnswerRe: Visual Studio and Windows SDKs - need some experienced comments about SDK usage and RTLs Pin
Richard MacCutchan11-Jun-20 21:32
mveRichard MacCutchan11-Jun-20 21:32 
AnswerRe: Visual Studio and Windows SDKs - need some experienced comments about SDK usage and RTLs Pin
Mircea Neacsu12-Jun-20 2:24
Mircea Neacsu12-Jun-20 2:24 
GeneralRe: Visual Studio and Windows SDKs - need some experienced comments about SDK usage and RTLs Pin
charlieg12-Jun-20 8:27
charlieg12-Jun-20 8:27 
GeneralRe: Visual Studio and Windows SDKs - need some experienced comments about SDK usage and RTLs Pin
Mircea Neacsu12-Jun-20 8:59
Mircea Neacsu12-Jun-20 8:59 
QuestionRecursion to normal way Pin
iNoor728-Jun-20 9:28
iNoor728-Jun-20 9:28 
AnswerRe: Recursion to normal way Pin
jeron18-Jun-20 9:47
jeron18-Jun-20 9:47 
GeneralRe: Recursion to normal way Pin
iNoor728-Jun-20 11:00
iNoor728-Jun-20 11:00 
GeneralRe: Recursion to normal way Pin
David Crow9-Jun-20 3:15
David Crow9-Jun-20 3:15 
GeneralRe: Recursion to normal way Pin
harold aptroot8-Jun-20 10:30
harold aptroot8-Jun-20 10:30 
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 | :)

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.