Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
72657 李琥博 打印杨辉三角 C++ Accepted 2 MS 276 KB 356 2024-05-12 11:13:44

Tests(15/15):


Code:

#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; int a[31][31]; for(int i=0;i<31;i++){ for(int j=0;j<31;j++){ a[i][j]=0; } } a[1][1]=1; cout<<a[1][1]<<endl; for(int i=2;i<=n;i++){ for(int j=1;j<=i;j++){ a[i][j]=a[i-1][j]+a[i-1][j-1]; cout<<a[i][j]<<" "; } cout<<endl; } return 0; }