• 大小: 2.75KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-02-21
  • 标签:

资源简介

C++实战源码-使用递归过程实现阶乘运算(入门级实例197).zip

资源截图

代码片段和文件信息

// factorial.cpp : Defines the entry point for the console application.
//

#include “stdafx.h“

int factorial(int n);// 递归函数


int main()
{
   printf(“5的阶乘为:%d“factorial(5));//输出5的阶乘
   printf(“\n“);
   return 0;
}

//阶乘的计算
int factorial(int n)
{
   if ((n==0)||(n==1))
     return 1;
   else
   {
      return  n*factorial(n-1);
   }
}




 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件         389  2010-10-13 10:37  factorial\factorial.cpp
     文件        4572  2010-10-13 10:34  factorial\factorial.dsp
     文件         543  2010-10-13 10:34  factorial\factorial.dsw
     文件         296  2010-10-13 10:34  factorial\StdAfx.cpp
     文件         769  2010-10-13 10:34  factorial\StdAfx.h

评论

共有 条评论