Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
96860 | 只因你太美(Ikun 真爱粉) | 打印貌似杨辉三角 | C++ | Accepted | 1 MS | 276 KB | 677 | 2024-11-09 17:09:45 |
#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 n;int a[31][31]={0}; cin>>n; for(int i=1;i<=n;i++){ for(int j=1;j<=i;j++){ if(j==1){a[i][1]=i;continue;} if(j==i){a[i][j]=i;continue;} a[i][j]=a[i-1][j]+a[i-1][j-1]; } } for(int i=1;i<=n;i++){cout<<i; for(int j=2;j<=i;j++){ cout<<" "<<a[i][j]; } cout<<endl; } return 0; }