算法训练 6-1 递归求二项式系数值

//递归求二项式系数值  
#include <stdio.h>
int rec(int k, int n){
    int c;
    if(k == n || k == 0) return 1;
    if(k>0 && k<n){
        return rec(k, n-1)+rec(k-1, n-1);
    }
    return c;
}
void Deal(void){
    int n, k;
    scanf("%d %d", &k, &n);
    printf("%d", rec(k, n));
    return;
}

int main(void){
    Deal();
    return 0;
} 
递归求二项式系数值  
题如图

 


posted @ 2017-02-17 10:53  ZaleJ  阅读(1356)  评论(0编辑  收藏  举报