Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
139790 郝王骏程 打印貌似杨辉三角 C++ Accepted 1 MS 288 KB 731 2025-12-08 20:47:48

Tests(10/10):


Code:

#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ int e,s=0; long long a[31][31]; a[1][1]=1; cin>>e; for(int i=0;i<=e;i++){ for(int j=0;j<=e;j++){ a[i][j]=1; } } for(int i=2;i<=e;i++){ for(int j=1;j<=i;j++){ a[i][j]=a[i-1][j-1]+a[i-1][j]; } } for(int i=1;i<=e;i++){ for(int j=1;j<=i;j++){ if(i==j) cout<<a[i][j]; else cout<<a[i][j]<<" "; } cout<<endl; } return 0; }