14.从m个球中取出n个球的所有组合情况

#include<iostream>
using namespace std;
int JieCheng(int);

int main()
{
    int m,n;
    int x;
    cout<<"please input an number: "<<endl;
    cin>>n>>m;
    x=JieCheng(m)/(JieCheng(n)*JieCheng(m-n));
    cout<<x<<endl;
    return 0;
}

int JieCheng(int index)
{
    int p=1;
    for(int i=1;i<=index;i++)
    {
        p*=i;
    }
    return p;
}

 

posted on 2014-08-04 17:50  Ji_xiaowu  阅读(155)  评论(0编辑  收藏  举报

导航