5.5打卡

#include <bits/stdc++.h>
using namespace std;
int comm(int n,int k)
{
    if(k>n)
    return 0;
    else if(n==k||k==0)
    return 1;
    else
    return comm(n-1,k)+comm(n-1,k-1);
}
int main()
{
    int n,k;
    cout<<"Enter two integers n and k: ";
    cin>>n>>k;
    cout<<"C(n,k)="<<comm(n,k)<<endl;
    return 0;
}

 

posted @ 2023-05-05 15:18  记得关月亮  阅读(7)  评论(0编辑  收藏  举报