Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
120850 黎瑾萱 打印杨辉三角 C++ Accepted 1 MS 276 KB 347 2025-06-01 11:26:31

Tests(15/15):


Code:

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