/* 循环写阶乘 */
4 5 #include<stdio.h> 6 int main() 7 { 8 int sum = 1; 9 int i; 10 for (i = 1; i < 100;i++) 11 { 12 sum *= i; 13 } 14 printf("%d", sum); 15 16 17 return 0; 18 }
1 /* 2 递归写阶乘 3 */ 4 5 #include<stdio.h> 6 int mult(int num) 7 { 8 if (num==1) 9 { 10 return 1; 11 } 12 return num*mult(num - 1); 13 14 } 15 int main() 16 { 17 int sum; 18 sum = mult(10); 19 printf("%d", sum); 20 21 22 return 0; 23 }
原文地址:https://www.cnblogs.com/old-horse/p/12685744.html
时间: 2025-01-02 00:02:58