我可能是在做一波水题练手感。
#include<iostream>
#include<cstring>
using namespace std;
int main(){
int n;
scanf("%d",&n);
printf("1\n");
int up[35];
int down[35];
memset(up,0,sizeof(up));
memset(down,0,sizeof(down));
up[0]=1;
for(int i=1;i<n;i++){
for(int j=0;j<=i;j++){
if(j==0||j==i){
down[j]=1;
}
else{
down[j]=up[j-1]+up[j];
}
}
for(int j=0;j<=i;j++){
printf("%d ",down[j]);
up[j]=down[j];
}
printf("\n");
}
return 0;
}
来源:CSDN
作者:han_hhh
链接:https://blog.csdn.net/han_hhh/article/details/104340539