'commit'
This commit is contained in:
21
C++专题课程/基础知识/杨辉三角.cpp
Normal file
21
C++专题课程/基础知识/杨辉三角.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main () {
|
||||
int n,i,j,k,w;
|
||||
scanf("%d",&n);
|
||||
int a[35][35]= {0};
|
||||
n=n-1;
|
||||
a[0][0]=1;
|
||||
for(i=0; i<=n; i++) {
|
||||
for(j=0; j<i; j++) {
|
||||
a[i][0]=1;
|
||||
a[i][j+1]=a[i-1][j] +a[i-1][j+1];
|
||||
}
|
||||
for(k=0; k<=i; k++)
|
||||
printf("%d ",a[i][k]);
|
||||
printf("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user