#include<iostream> #include<math.h> using namespace std; int main(){ int n; cout<<"请输入打印行数:"; cin>>n; int a[n-1][n-1]; for(int i=0;i<=n-1;i++){ for(int j=0;j<=i;j++){ if(j==0){ a[i][j]=1; cout<<a[i][j]<<"\t"; continue; } if(j==i){ a[i][j]=1; cout<<a[i][j]; continue; } a[i][j]=a[i-1][j-1]+a[i-1][j]; cout<<a[i][j]<<"\t"; } cout<<"\n"; } return 0; }
初级程序员
by: 赶蚊子 发表于:2017-06-20 11:08:33 顶(0) | 踩(0) 回复
好玩
回复评论