考点:组合数
=
+
即 fun(n,m)
#include<bits/stdc++.h>
using namespace std;
const int MAXSIZE=1001;
int fun(int n,int m);
int main() {
int n;
while(cin>>n) {
int i,j;
for(i=1; i<n; i++) {
for(j=0; j<i; j++) {
cout<<fun(i,j)<<" ";
}
cout<<fun(i,i)<<endl;
}
}
return 0;
}
int fun(int n,int m) {
if(m==0||n==m) {
return 1;
}
return fun(n-1,m-1)+fun(n-1,m);
}
最后
以上就是时尚寒风最近收集整理的关于牛客网考研机试题集合:杨辉三角形的全部内容,更多相关牛客网考研机试题集合内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复