斐波那契数列

来源:互联网 发布:阿sa长相 知乎 编辑:程序博客网 时间:2024/05/29 17:40

只是一道简单的递归,不讲了,自己看看程序就会了!

#include<stdio.h>#include<stdlib.h>#include<math.h>#include<time.h>int f(int x){    if(x==1  ||  x==2)            return 1;    else            return f(x-1)+f(x-2);   }int main(){    int n;    scanf("%d",&n);    printf("%d",f(n));     system("pause");    return 0;   }


1 1
原创粉丝点击