提交时间:2024-05-25 19:17:22
运行 ID: 149231
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; int a[n+1][n+1],i,j; a[1][1]=1;a[2][1]=1;a[2][2]=1; for(i=1;i<=n;i++){ for(j=1;j<=i;j++){ if(i>2&&j>=2&&j<i){ a[i][j]=a[i-1][j-1]+a[i-1][j]; } else{ a[i][j]=1; } cout<<a[i][j]<<" "; } cout<<endl; } return 0; }