摘要:
普通递归与尾递归的区别 普通递归(图): 尾递归(图): 对比普通递归和尾递归,两者的求和操作的执行点是不同的: 普通递归: 求和操作是在“归”的过程中执行的,每层返回后都要再执行一次求和操作。 尾递归: 求和操作是在“递”的过程中执行的,“归”的过程只需层层返回。 阅读全文
posted @ 2024-07-15 19:03
星火splanet0
阅读(69)
评论(0)
推荐(0)
摘要:
#include<stdio.h> #include<string.h> #include<stdlib.h> //双层for循环 char *nestedForLoop(int n){ //nested --嵌套 int size = n * n * 26 + 1; char * res = ma 阅读全文
posted @ 2024-07-15 16:54
星火splanet0
阅读(17)
评论(0)
推荐(0)
摘要:
#include<stdio.h> //while循环 int whileLoop(int n){ int res = 0; int i = 1;//初始化条件变量 //循环求和:1+2+3+...+n while (i <= n){ res += i; i++; } return res; } i 阅读全文
posted @ 2024-07-15 16:52
星火splanet0
阅读(11)
评论(0)
推荐(0)
摘要:
#include<stdio.h> //for循环 int forLoop(int n){ int res = 0; //循环求和:1+2+3+...+n for (int i = 1; i <= n; i++){ res += i; } return res; } int main(){ int 阅读全文
posted @ 2024-07-15 16:24
星火splanet0
阅读(14)
评论(0)
推荐(0)
浙公网安备 33010602011771号