当前位置:网站首页>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 :
边栏推荐
- 二分查找
- China hydraulic cylinder linear position sensor market trend report, technical dynamic innovation and market forecast
- Smart management of green agriculture: a visual platform for agricultural product scheduling
- Lake shore PT-100 platinum resistance temperature sensor
- Sorting out the knowledge points of primary and secondary indicators
- Data visualization - biaxial comparison effect
- 好数对的求解
- leetcode:210. 课程表 II
- [tutorial] detailed explanation of the page rules parameter settings of cloudflare CDN
- Junda technology is applicable to "kestar" intelligent precision air conditioning network monitoring
猜你喜欢
Li Mu [practical machine learning] 1.4 data annotation
测试基础之:单元测试
Integrated monitoring solution for power environment of small and medium-sized computer rooms
一款高颜值的MySQL管理工具
The salted fish has been transmitted for 5W times, and the latest spring recruit face-to-face test questions of bytes have been leaked
Leetcode: 210. Programme II
shell语言
Risk control modeling X: Discussion on problems existing in traditional modeling methods and Exploration on improvement methods
@loadbalance annotation of resttemplate
#113 Path Sum II
随机推荐
测试基础之:单元测试
Circularly insert one excel column and the sum of multiple columns
Understanding of closures
选择排序
模块八:设计消息队列存储消息数据的MySQL表
Lombok package is successfully installed, but the runtime prompts that get, set method and constructor solution cannot be found
GNS installation and configuration
C language learning notes (II)
Composer version degradation
Cv2.lut() (populates the output array with values from the lookup table)
#113 Path Sum II
leetcode:210. Schedule II
Data visualization - broken line area chart
ASCII 码对照表
#113 Path Sum II
JSON file handles object Tags
CUDA out of memory
What are the disadvantages of bone conduction earphones? Analysis of advantages and disadvantages of bone conduction earphones
Solve one-dimensional array prefix sum
Compréhension préliminaire des expressions régulières cognitives (regex)