zoukankan      html  css  js  c++  java
  • 戴维营第五天上课总结

    今天大茶给我们讲了C语言的递归以及函数的调用, 函数的调用, 可以在其他文件中创建函数的源文件, 在main文件中进行调用, 可以节俭在main函数的多行代码, 一旦程序出错, 调试起来也非常的方便, 不需要在一大段的代码中慢慢寻找一些细小的错误.

    递归的使用有些类似于循环, 一样有判断语句, 当判断语句不成立的时候, 跳过判断语句的条件, 进行到else语句进行递归运算, 一直到不满足条件为止.

    #include <stdio.h>
    int f(int n);
    int n;
    int main(int argc, const char * argv[])
    {
        printf("%d
    ", f(10));
    }
    int f (int n)
    {
        if(n==1||n==2)
        {
            return 1;
        }
        else
        {
            return  f(n-1)+f(n-2);
        }
    }

    函数原型1

    #include "file1.h"
    int b;

    函数原型2

    #include "file2.h"
    int a;

    main函数

    #include <stdio.h>
    int f(int n);
    int n;
    int main(int argc, const char * argv[])
    {
        printf("%d", f(6));
    }
        int f (int n)
        {
            if(n==1||n==2)
            {
            return 1;
            }
            else
            {
                return  f(n-1)+f(n-2);
            }
    }
  • 相关阅读:
    Codeforces Round #609 (Div. 2)
    Educational Codeforces Round 78 (Rated for Div. 2)
    Codeforces
    crontab
    C6 C7的开机启动流程
    平均负载压力测试
    ps 和 top
    if判断
    使用3种协议搭建本地yum仓库
    linux rpm包
  • 原文地址:https://www.cnblogs.com/iOSCain/p/3985362.html
Copyright © 2011-2022 走看看