解题思路:
注意事项:
参考代码:
#include <iostream>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <string>
#include <cmath>
#include <cstdlib>
#include <string.h>
using namespace std;
int f(int i,int j)
{
if(i==0||j==i)
{
return 1;
}
if(j==0)
{
return 1;
}
return f(i-1,j)+f(i-1,j-1);
}
int main()
{
int n;
while(cin>>n)
{
for(int i=0;i<n;i++)
{
for(int j=0;j<=i;j++)
{
cout<<f(i,j)<<" ";
}
cout<<endl;
}
cout<<endl;
}
return 0;
}
0.0分
0 人评分
母牛的故事 (C语言代码)浏览:671 |
【回文数(二)】 (C++代码)浏览:874 |
计算质因子 (C++代码)浏览:1647 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:1295 |
WU-陶陶摘苹果2 (C++代码)浏览:975 |
A+B for Input-Output Practice (VII) (C语言代码)浏览:528 |
简单的a+b (C语言代码)浏览:952 |
The 3n + 1 problem (C语言代码)浏览:505 |
判定字符位置 (C语言代码)浏览:799 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:520 |