#include<iostream> using namespace std; void main(){ int s[30][30]; for(int i=0;i<30;++i){ for(int j=0;j<=i;++j){ if(j==0||i==j) { s[i][j]=1; } } } for(int w=2;w<30;++w){ for(int q=1;q<w;++q){ s[w][q]=s[w-1][q]+s[w-1][q-1]; } } int n; while(cin>>n&&(n>=1&&n<=30)){ for(int x=0;x<n;++x){ bool t=true; for(int z=0;z<=x;++z){ if(t){ t=false; cout<<s[x][z]; } else{ cout<<" "<<s[x][z]; } } cout<<endl; } cout<<endl; } }
杭电ACM 第2032题
最新推荐文章于 2020-04-03 17:05:41 发布