复习题 奇数阶乘

来源:互联网 发布:socket.io.js 教程 编辑:程序博客网 时间:2024/06/05 12:55


#include<iostream>  
using namespace std;  
int fac(int x);  
int main()  
{  
    int n,m=0;  
    cin>>n;  
    m=fac(n);  
    cout<<m<<endl;  
    return 0;  
}  
int fac(int x)  
{  
    if(x==0||x==1)  
        return 1;  
    else  
        return x*fac(x-2);  
}  
0 0
原创粉丝点击