题解 | #Fibonacci#

Fibonacci

https://www.nowcoder.com/practice/17ad6908e36a49f4b06ea96936e8bb25

#include<iostream>
#include<algorithm>
using namespace std;

int fib(int n){
	
	if(n == 0) return 0;
	
	if(n == 1) return 1;
	
	return fib(n - 1) + fib(n - 2); 
	
}

int main(){
    
    int n;
	while(cin>>n){
		cout<<fib(n)<<endl;
	}
    
    return 0;
}

王道考研机试 文章被收录于专栏

包含考研机试打卡表题目

全部评论

相关推荐

10-22 19:44
门头沟学院 Java
KKorz:我以为又疯一个呢,你来真的啊?
点赞 评论 收藏
分享
叁六玖:你看,最后不是让你加油,就是鼓励你,还祝福你求职顺利。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务