采用递归方法计算n的阶乘 当n为负数时返回-1。
已帮助 人
回答
共1条回复-
<br>递归算法:<br> int factorial(int n)<br> {<br> if(n==0) return 1;<br> else return factorial(n-1)*n;<br>}

