用递归方法求解(2)

来源:互联网 发布:长戟大兜虫淘宝 编辑:程序博客网 时间:2024/06/18 06:39

/*
*Copyright (c) 2016,烟台大学计算机学院
*All rights reserved.
*文件名称:text.cpp
*作者:汤善晔
*完成日期:2016年8月22日
*版本号:v1.0
 */

#include <iostream>     

using namespace std;    
long int func1(int n);    
int main()    
{    
    int n,y;    
    cin>>n;    
    y=func1(n);    
    cout<<y<<endl;    
    return 0;    
}    
long int func1(int n)    
{    
    long int f;    
    if(n==1)    
        f=1;    
    else    
        f=n*func1(n-2);    
    return f;    

}   



0 0