Feibolaqi brief summary of the number of columns

Feibolaqi series summary

Questions raised:

It was calculated using recursive and non-recursive codes Feibolaqi series; Comparative efficiency reasons, the analysis efficiency differences may occur.
 
#include <stdio.h> 
#include <stdlib.h>
 // recursive 
int List ( int n-) {
     IF (n-== 0 || n-== . 1 )
         return  . 1 ;
     the else  IF (n-> . 1 )
         return List (N- . 1 ) + List (N- 2 );
     the else 
        return  0 ; 
} 
// non-recursive 
int text ( int n-) {
     int I, SUM, SUM1, SUM2;
     for (I = 0 ; I <= n-; ++ I ) {
        if(i==0||i==1){
            sum=1;
            sum1=sum;
            sum2=sum;
        }
        else{
            sum=sum1+sum2;
            sum1=sum2;
            sum2=sum;
        }
    }
    return sum;
}
int main(){
    int n;
    printf("请输入n的大小");
    scanf("%d", & N-); 
    List (n-); 
    text (n-); 
    the printf ( " recursive: Feibolaqi series is: D% \ n- " , List (n-)); 
    the printf ( " non-recursive: Feibolaqi is the number of columns:% D " , text (n-)); 
    System ( " PAUSE " ); 
}

Screenshot results:

Guess you like

Origin www.cnblogs.com/codercql/p/11925458.html