当前位置:网站首页>Experiment 7-2-6 print Yanghui triangle (20 points)
Experiment 7-2-6 print Yanghui triangle (20 points)
2022-06-12 21:24:00 【YYY speaker】
Print Yanghui triangle
This question is required to be printed according to the specified format N Go Yanghui triangle .( Difficulty four stars )
Ideas :
Use a two-dimensional array
Code :
#include<stdio.h>
int main(){
int a[10][10];// Use a two-dimensional array
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
// peripheral
a[i][0]=1;
a[i][i]=1;
}
for(int i=2;i<n;i++){
for(int j=1;j<i;j++){
a[i][j]=a[i-1][j-1]+a[i-1][j];
// middle
}
}
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++)
printf(" ");
for(int j=0;j<=i;j++)
{
printf("%4d",a[i][j]);
//printf("\t");
}
printf("\n");
}
return 0;
}
result :

边栏推荐
- Distributed cloud service developer'allegro Xile technology 'received an angel round financing of US $3million
- Shell language
- Principales étapes de la collecte des ordures à Zgc
- @loadbalance annotation of resttemplate
- China hydraulic cylinder linear position sensor market trend report, technical dynamic innovation and market forecast
- What's a good gift for the goddess Festival? Gift recommendation for the goddess Festival on March 8
- zgc 并发标识和并发转移阶段的多视图地址映射
- Binary search
- How to improve communication efficiency during home office | community essay solicitation
- 初步了解認識正則錶達式(Regex)
猜你喜欢

Design and practice of Hudi bucket index in byte skipping

torch. nn. Linear() function

nn. PReLU(planes)

What are the disadvantages of bone conduction earphones? Analysis of advantages and disadvantages of bone conduction earphones

Data visualization - Calendar chart

Data visualization - broken line area chart
![Li Mu [practical machine learning] 1.4 data annotation](/img/e4/2593b1dec04476a9cc3b4af94dc189.jpg)
Li Mu [practical machine learning] 1.4 data annotation

结构体知识点all in

Risk control modeling X: Discussion on problems existing in traditional modeling methods and Exploration on improvement methods

Leetcode: 210. Programme II
随机推荐
shell语言
Integrated monitoring solution for power environment of small and medium-sized computer rooms
USB机械键盘改蓝牙键盘
好数对的求解
ASCII 码对照表
torch. clamp_ min_ method
Fill in the checklist & lt; int&gt; Have default values? [repeat] - fill list & lt; int&gt; with default values? [duplicate]
同花顺能开户吗,在APP上可以直接开通券商安全吗
ATOI super resolution
The year of the outbreak of financial innovation! All dtinsight products of kangaroo cloud data stack have passed the special test of Xinchuang of ICT Institute
Understanding of closures
Algorinote_ 2_ Main theorem and Akra bazzi theorem
竣达技术丨适用于“科士达”智能精密空调网络监控
atoi超强解析
ASCII code comparison table
leetcode:210. 课程表 II
Can flush open an account? Can you directly open the security of securities companies on the app
InRelease: 由于没有公钥,无法验证下列签名: NO_PUBKEY EB3E94ADBE1229CF
Cv2.lut() (populates the output array with values from the lookup table)
Allegro Xile technology, a developer of distributed cloud services, received millions of dollars of angel round financing and was independently invested by Yaotu capital