C语言递归的使用
(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;
}

一勤天下无难事。

浙公网安备 33010602011771号