正在加载图片...
上海交通大学交大密西根 ·联合学院一 ■ 81 UM-SJTU Joint Institute University of Michigan Shanghal Jiao Tong University Recursion code Now for the void printStr(string str) conceptual leap:we ConsoleT console; can use the same if (Istr.empty ( { function we are console.printLine(str[0],endl); defining to solve the printstr (str.substr(1,str.length()); rest of the problem! That is,we can print This is a simpler problem and the rest of the string it has the same form and by having PrintString it will converge at finite steps of call itself. iterations.Recursion Code Recursion Code • Now for the conceptual leap: we can use the same function we are defining to solve the rest of the problem! • That is, we can print the rest of the string by having PrintString call itself. • This is a simpler problem and • it has the same form and • it will converge at finite steps of iterations
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有