#include
#include
using namespace std;
#define N 20
/* run this program using the console pauser or add your own getch, system(“pause”) or input loop */
int main() {
int i,j,a[N][N],n;
cout<<“二项式的项数为:”;
cin>>n;
cout<<endl;
for(i=0;i<=n;i++) //行数
for(j=0;j<=i;j++)
if((ij)||(j0))
a[i][j]=1;
else
a[i][j]=a[i-1][j-1]+a[i-1][j];
//输出
for(i=0;i<=n;i++){
for(j=0;j<=i;j++)
cout<<setw(4)<<a[i][j];
cout<<endl;
}
return 0;
}
运行结果:
06-17
782
02-02
2415
04-25
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交