题解 | #统计每个月兔子的总数#

统计每个月兔子的总数

https://www.nowcoder.com/practice/1221ec77125d4370833fd3ad5ba72395

#include <iostream>
using namespace std;

int rabbit(int one,int two,int three,int n){
    int tem;
    while(n--){
        three = three + two;
        two = one;
        one = three;
    }
    return one+two+three;
}

int main() {
    int n;
    while (cin >> n) { 
        cout<<rabbit(1, 0, 0, n-1)<<endl;
    }
}

全部评论

相关推荐

野猪不是猪🐗:这种直接口头上答应,骗面试,面完了直接拉黑,相当于给自己攒面经了(
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务