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

问题描述
样例输入
一个满足题目要求的输入范例。
3 10
样例输出
与上面的样例输入对应的输出。
数据规模和约定
  输入数据中每一个数的范围。
  例:结果在int表示时不会溢出。
 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <algorithm>
 5 #include <cmath>
 6 using namespace std;
 7 int deal(int k,int n)
 8 {
 9     if(k==0||k==n){
10         return 1;
11     }
12     if(0<k&&k<n){
13         return deal(k,n-1)+deal(k-1,n-1);
14     }
15 }
16 int main()
17 {
18     int x,y;
19     while(cin>>x>>y){
20         cout<<deal(x,y)<<endl;
21     }
22      return 0;
23 }

 

posted @ 2019-03-15 15:30  wydxry  阅读(488)  评论(0)    收藏  举报
Live2D