#includeusing namespace std;int fun(int n, int fromPos, int toPos) {\tint t, tot;\tif (n == 0)\t\treturn 0;\tfor (t = 1; t <= 3; t )\t\tif (t != fromPos && t != toPos)\t\t\tbreak;\ttot = 0;\ttot = fun(n - 1, fromPos, t);\ttot ;\ttot = fun(n - 1, t, toPos);\treturn tot;}int main() {\tint n;\tcin >> n;\tcout << fun(n, 1, 3) << endl;\treturn 0;}
输入:5
输出:_________
发表评论 取消回复