题解 | #跳台阶扩展问题#

跳台阶扩展问题

https://www.nowcoder.com/practice/953b74ca5c4d44bb91f39ac4ddea0fee

#include <stdio.h>

int caln(int n){
     if(n < 0){
        return -1;
     }
     if(n<=1){
        return 1;
     }else{
         int count=0;
         for(int i = 1; i <= n; i++){
            count+=caln(n-i);
         }
         return count;
     }
 }
int main() {
    int a = 7;   //2;
    scanf("%d", &a);
    printf("%d", caln(a));
    return 0;
}

全部评论

相关推荐

运营3年修炼中接简历辅导:你的科研项目经历里,只写了你的动作,没有写你的思考和成果,不要只写使用什么进行了什么,这等于罗列你的任务,简历是为了突出你的优秀,你在什么样的任务背景下,克服了什么样的困难,针对性地做了哪些事情,最后达成了什么成果(用数据体现你的成果和效率)
点赞 评论 收藏
分享
04-16 12:49
已编辑
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务