c:求n得阶乘(递归的应用)
2012-07-29 15:15
162 查看
#include<stdio.h> #include<stdlib.h> int main(void){ int c; c = factorial(5); printf("the res is: %d\n",c); system("pause"); //return 0; } int factorial(int a){ int res; if(a<0){ printf("error\n"); system("pause"); exit(EXIT_FAILURE); } if(a==1||a==0) res = 1; if(a>1) res = a*factorial(a-1); return res; }
相关文章推荐
- 12、数据结构笔记之十二栈的应用之栈与递归之阶乘实现
- 递归在阶乘上的应用
- java中递归方法的应用--计算n的阶乘
- Java递归应用:输出树形菜单
- 循环与递归求阶乘
- 汉诺塔——递归的应用
- Python3之递归应用
- 【学习点滴-数据结构-栈&队列】 栈的应用--递归的实现-汉诺塔
- 它处资料:数据结构学习笔记(12.递归的应用之八皇后回溯算法)
- 数据旋转及DB2递归的应用
- [代码应用]javaSE程序递归删除文件夹下的.bak文件程序源代码
- python 递归算阶乘
- 用递归实现阶乘计算器
- 递归实现n的阶乘
- 递归与循环的区别及应用
- 用递归方法计算n的阶乘n
- 数据结构之栈与递归的应用(汉诺塔递归解法)
- 高精度阶乘(递归版)
- 递归实现阶乘
- 利用递归求阶乘(某公司校园招聘笔试题目)