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

统计每个月兔子的总数

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;
    }
}

全部评论

相关推荐

06-25 16:00
武汉大学 Java
工科研究生底薪工资就开3k啊??
机械打工仔:写文章提成的岗位工资低,你怪工科?
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
06-24 14:18
点赞 评论 收藏
分享
asdasdasdasdas:19岁,不容易啊可能升个本会好点,现在学历歧视太严重了
点赞 评论 收藏
分享
机械打工仔:第一位颇有孟德之志
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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