001、
#include <stdio.h> int test(int n) // 定义函数 { if(n > 0) { return n * test(n - 1); // 调用函数自身, 终止条件是n = 0 } else { return 1; } } int main(void) { int num; printf("num = "); scanf("%d", &num); printf("result: %d\n", test(num)); return 0; }
标签:return,函数,递归,int,test,num,printf,阶乘 From: https://www.cnblogs.com/liujiaxin2018/p/16600652.html