There is a ladder, each can only walk 1 steps or 2 steps, the ladder from 0 to start counting, now enter the ladder order, to find a total number of ways to go.
Since each can only walk 1 steps or 2 steps, so go to the 3rd order, not from the 1th step, is to go from the 2nd step. Therefore, the 3rd-order method is the 1th-order method plus the 2nd-order method of the same way. So the analogy.
1 #define_crt_secure_no_warnings2 3#include <stdio.h>4#include <windows.h>5 6 DoubleTencent (intn);//if the value is too large, you need to use a double type7 8 Main ()9 {Ten intN; One Ascanf"%d", &n); - -printf"%f", Tencent (N)); the -System"Pause"); - } - + DoubleTencent (intN) - { + if(n = =1)//1th-order, 1-way approach A { at return 1; - } - Else if(n = =2)//2nd-order, 2-way approach - { - return 2; - } in Else - { to returnTencent (N-1) + Tencent (N-2); + } -}
Take the ladder _ Fepolaci