What is really happening in this code?

后端 未结 6 470
轮回少年
轮回少年 2020-12-03 16:51

I have a code which includes a recursive function. I have wasted a lot of time on recursion but I still couldn\'t get it really:

#include
void         


        
6条回答
  •  醉酒成梦
    2020-12-03 17:19

    While m is greater than 0, we call count. Here is a representation of the stack calls:

     count (m = 10)  
       count (m = 9)  
         count (m = 8)  
           count (m = 7)  
             count (m = 6)    
               count (m = 5)     
                 count (m = 4)     
                   count (m = 3)     
                     count (m = 2)     
                       count (m = 1)
                         count (m = 0)
                         printf 0
                       printf 1
                     printf 2
                   printf 3
                 printf 4
               printf 5
             printf 6
           printf 7
         printf 8
       printf 9
     printf 10
    

提交回复
热议问题