当前位置:网站首页>Basic exercise of test questions Yanghui triangle (two-dimensional array and shallow copy)
Basic exercise of test questions Yanghui triangle (two-dimensional array and shallow copy)
2022-06-13 02:07:00 【Jerry-hao】
The upper and left boundaries are added here , Easy to calculate
n = int(input())
b=[ [0]*(n+1) for i in range(n+1)]
b[1][1]=1
#print(" Before operation :",b)
for i in range(1,n):
i=i+1
for j in range(i):
j=j+1
b[i][j]=b[i-1][j-1] + b[i-1][j]
#print(' The first ',i,' That's ok ',b)
for i in range(n):
i = i+1
for j in range(i):
j=j+1
print(b[i][j],end=' ')
print()
The creation of two-dimensional array , Careful shallow copy :
How to create a two-dimensional array as well as python in [0 ]* n And [0 for _ in range(n)] The difference and connection _ Jiansheng Tudou's blog -CSDN Blog
To simplify the : Output directly after the operation
n = int(input())
b=[ [0]*(n+1) for i in range(n+1)]
b[1][1]=1
#print(" Before operation :",b)
print(b[1][1])
for i in range(1,n):
i=i+1
for j in range(i):
j=j+1
b[i][j]=b[i-1][j-1] + b[i-1][j]
print(b[i][j],end=' ')
print()
边栏推荐
- 回顾ITIL各版本历程,找到企业运维发展的关键点
- Ruixing coffee 2022, extricating itself from difficulties and ushering in a smooth path
- Delphi implements adding a column of serial number to the CXGRID list
- Gome's ambition of "folding up" app
- PyFlink实现自定义SourceFunction
- C language compressed string is saved to binary file, and the compressed string is read from binary file and decompressed.
- Luzhengyao, who has entered the prefabricated vegetable track, still needs to stop being impatient
- [the third day of actual combat of smart lock project based on stm32f401ret6 in 10 days] communication foundation and understanding serial port
- What did Hello travel do right for 500million users in five years?
- Swiper horizontal rotation grid
猜你喜欢

传感器:MQ-5燃气模块测量燃气值(底部附代码)
![[the 4th day of the 10 day smart lock project based on stm32f401ret6] what is interrupt, interrupt service function, system tick timer](/img/c4/0d97def5fb587b8301bcb907fc6fcf.jpg)
[the 4th day of the 10 day smart lock project based on stm32f401ret6] what is interrupt, interrupt service function, system tick timer

Huawei equipment is configured with CE dual attribution

Gome's ambition of "folding up" app

General IP address, account and password of mobile IPv6 optical cat login, and mobile optical cat is in bridging mode

Installing Oracle with docker for Mac
![[programming idea] communication interface of data transmission and decoupling design of communication protocol](/img/cd/896d1bcad556ffcbf1007bc984afeb.jpg)
[programming idea] communication interface of data transmission and decoupling design of communication protocol

Top level configuration + cooling black technology + cool appearance, the Red Devils 6S Pro is worthy of the flagship game of the year

C language compressed string is saved to binary file, and the compressed string is read from binary file and decompressed.

Uniapp preview function
随机推荐
华为设备配置双反射器优化虚拟专用网骨干层
Restrict cell input type and display format in CXGRID control
STM32 steering gear controller
rsync 傳輸排除目錄
Devaxpress Chinese description --tcxpropertiesstore (property store recovery control)
华为设备配置IP和虚拟专用网混合FRR
[analysis notes] source code analysis of siliconlabs efr32bg22 Bluetooth mesh sensorclient
The execution results of i+=2 and i++ i++ under synchronized are different
In addition to the full screen without holes under the screen, the Red Devils 7 series also has these black technologies
Application and examples of C language structure
[sequence structure, branch structure, loop structure, continue statement, break statement, return statement] (learning Note 6 -- C language process control)
C language compressed string is saved to binary file, and the compressed string is read from binary file and decompressed.
Devaxpress Chinese description -- tdxgallerycontrol object (gallery component)
CCF 201409-1: adjacent number pairs (100 points + problem solving ideas)
rsync 传输排除目录
华为设备配置虚拟专用网FRR
The first cell of devaxpress CXGRID after inserting a row is in focus editing status
万字讲清 synchronized 和 ReentrantLock 实现并发中的锁
Opencv camera calibration (1): internal and external parameters, distortion coefficient calibration and 3D point to 2D image projection
移动IPv6光猫登录的一般ip地址账号与密码,移动光猫变桥接模式