Thinking: A recursive program (suddenly understood)

xiaoxiao2021-03-06  89

After studying C, I learned to recurrent, but later a little blur, today religbit this algorithm from a program, if a method is recursive, and there is a println in the method, the method keeps calling yourself to know the termination condition. Not each call will println, but put things to Println to be there, and finally output, the first println's thing in the bottom. . .

May continue to add

Class RECTEST {Int Values ​​[]; Rectest (INT i) {VALUES = New INT [I];} Void PrintArray (INT i) {if (i == 0) Return; Else PrintArray (I-1); System.out .println ("[[" (i-1) "] value [i-1]);}} Class Recursion2 {public static void main (string args []) {rectest ob = New RECTEST (10); INT i; for (i = 0; i <10; i ) ob.values ​​[i] = i; ob.printArray (10);}}

operation result:

[0] 0 [1] 1 [2] 2 [3] 3 [4] 4 [5] 5 [6] 6 [7] 7 [8] 8 [9] 9

转载请注明原文地址:https://www.9cbs.com/read-125002.html

New Post(0)