void func(int num){ if(num< 3){ printf("%d ", num); func(num+ 1); printf("%d ", num); } }
Suppose I call this function with func (0). Why is the result 0 1 2 2 1 0? I do not know why this is decreasing.
Here's the stack trace
f(0) print 0 f(1) print 1 f(2) print 2 f(3) // 3 < 3 == false print 2 print 1 print 0
Source: https://habr.com/ru/post/1651456/More articles:@NgModule - is this new? - angularF # Functional reactive programming using graphical interfaces - frp"illegal loopback involving InterfaceAudience" when using reflection Scala 2.11 - scalaGet component for kids / kids using viewContainerRef in Angular2 - angularngTable not sorting? - sortingSet margin on RecyclerView programmatically - androidProblems understanding how recursion works in C - cReact.js and HTML5 authentication - javascriptWebGL: индекс цикла не может сравниваться с неопределенным выражением - webglSpacy Pipeline? - pythonAll Articles