The second question: the question of the Progress(1) A frog can jump to level 1 or Level 2 at a time. Find the total number of hops that the frog jumps to an n-level step. (2) A frog can jump to level 1 or Level 2 at a time ...... It can also jump to N levels. How many jumping methods does the frog jump to an n-level step?
# Include <stdio. h> # include <stdlib. h> int main (int ac, int * AV []) {int num_steps, result; printf ("Please input the num of steps \ n "); scanf ("% d", & num_steps); Result = 0; Result + = cal_steps (num_steps); printf ("there are % d ways for the frog to pass % d steps. \ n ", result, num_steps);} int cal_steps (int n) {int I, j, * A; A = (int *) malloc (N * sizeof (INT); a [0] = 1; A [1] = 2; for (I = 2; I <n; I ++) {for (j = 0; j <I; j ++) A [I] + = A [J]; A [I] + = 1 ;} return a [n-1];} int cal_steps_two (int n) {int I, pre, result, TMP; If (n = 1) return 1; if (n = 2) return 2; If (n> 2) {pre = 1; Result = 2; for (I = 2; I <n; I ++) {TMP = result; result = Result + pre; Pre = TMP;} return result;} int cal_steps_recursive (int n) {int steps; Steps = 0; If (n = 0) | (n <0) {return 0;} If (n = 1) return 1; if (n = 2) return 2; If (n> 2) {steps + = cal_steps (n-1) + cal_steps (n-2);} return steps ;}