nowroot

(1)尾巴递归,什么时候递归结束.实现想要的递归终止条件.

(2)如何递归和返回想要的值  相加还是相减  return  xx*xx;

(3)递归函数的编写和递归调用和功能需求. 

 

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <time.h>
#include <pthread.h>
#include <semaphore.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <stdlib.h>


// 1+2+3+4+5
static int  fun(int n)
{
    if(n<=1000)
    {
        return n+fun(n+1);
    }
    else
    {
         return 0;
    }
}

int main()
{

    printf("%d\n",fun(1));
    for(;;);
    return 0;
}

  

分类:

技术点:

相关文章:

  • 2021-11-13
  • 2021-04-22
  • 2021-11-13
  • 2021-11-13
  • 2021-11-11
  • 2021-12-06
  • 2021-11-13
  • 2021-11-13
猜你喜欢
  • 2021-11-13
  • 2021-11-13
  • 2021-06-27
相关资源
相似解决方案