阶乘
int factorial(int num) { if (num == 1) { return 1; } return num * factorial(num - 1); }
数组求和
int arraySum(int* arr, int length, int index) { if (index == length) { return 0; } return arr[index] + arraySum(arr, length, index + 1); }
int factorial(int num) { if (num == 1) { return 1; } return num * factorial(num - 1); }
int arraySum(int* arr, int length, int index) { if (index == length) { return 0; } return arr[index] + arraySum(arr, length, index + 1); }
来源:https://www.cnblogs.com/esrevinud/p/11980275.html