且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

河内塔柜台

更新时间:2023-12-01 17:02:40

doTowers的返回类型从void更改为int,并将返回值设置为:

Change the return type of doTowers from void to int, and set the return value to:

  1. 如果topN == 1,则返回1;
  2. 否则返回两个doTowers()加1的总和.
  1. if topN == 1, return 1;
  2. else return the sum of two doTowers() plus 1.

逻辑类似于问题的算法.玩弄找出来吧!

The logic is similar to the algorithm of the problem. Have fun figuring it out!

您还可以使用静态全局变量,但这可以说是不好的编程风格.

You could also use a static global variable, but that's arguably bad programming style.