当前位置:网站首页>Example 008: 99 multiplication table
Example 008: 99 multiplication table
2022-07-05 08:22:00 【Lazy smile】
example 008: multiplication table
subject : Output 9*9 Multiplication table .
Program analysis : Branch and column considerations , common 9 That's ok 9 Column ,i The control line ,j Control the column .
# The first i Yes i Column ,range It is a semi closed and semi open interval, so range Need to go to i+1 # For better output , Set the result of multiplication to %-2d That accounts for 2 position ,- Indicates left alignment , No addition - Is the default right alignment end='' That is, no line break after output
The code is as follows :
for i in range(1, 10):
for j in range(1, i + 1): # The first i Yes i Column ,range It is a semi closed and semi open interval, so range Need to go to i+1
print('%d*%d=%-2d ' % (i, j, i * j), end='') # For better output , Set the result of multiplication to %-2d That accounts for 2 position ,- Indicates left alignment , No addition - Is the default right alignment end='' That is, no line break after output
print() # Line break The output is as follows :
1*1=1
2*1=2 2*2=4
3*1=3 3*2=6 3*3=9
4*1=4 4*2=8 4*3=12 4*4=16
5*1=5 5*2=10 5*3=15 5*4=20 5*5=25
6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36
7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49
8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64
9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81 
边栏推荐
- Explication de la procédure stockée pour SQL Server
- [tutorial 15 of trio basic from introduction to proficiency] trio free serial communication
- C, Numerical Recipes in C, solution of linear algebraic equations, LU decomposition source program
- Basic information commands and functions of kernel development
- Detailed summary of FIO test hard disk performance parameters and examples (with source code)
- Problem solving: interpreter error: no file or directory
- WiFi wpa_ Detailed description of supplicant hostpad interface
- [trio basic tutorial 18 from introduction to proficiency] trio motion controller UDP fast exchange data communication
- leetcode - 445. 两数相加 II
- STM32 --- configuration of external interrupt
猜你喜欢
![[tutorial 15 of trio basic from introduction to proficiency] trio free serial communication](/img/08/7f28008a4aa999650998ba8dee5d8e.jpg)
[tutorial 15 of trio basic from introduction to proficiency] trio free serial communication

Shell script
![Shape template matching based on Halcon learning [VII] reuse_ model. Hdev routine](/img/55/0f05291755dc1c3c03db8e991a1ba1.jpg)
Shape template matching based on Halcon learning [VII] reuse_ model. Hdev routine

On boost circuit
![C WinForm [help interface - send email] - practice five](/img/2a/c4e7abe054e6fdd45acc7d297a033d.jpg)
C WinForm [help interface - send email] - practice five

【云原生 | 从零开始学Kubernetes】三、Kubernetes集群管理工具kubectl

UE像素流,来颗“减肥药”吧!
![Halcon's practice based on shape template matching [1]](/img/68/206eed7502fbf108a929aa9365b1ae.jpg)
Halcon's practice based on shape template matching [1]

Volatile of C language

Introduction of air gap, etc
随机推荐
Bluetooth hc-05 pairing process and precautions
Carrier period, electrical speed, carrier period variation
Shape template matching based on Halcon learning [viii] PM_ multiple_ models. Hdev routine
STM32 outputs 1PPS with adjustable phase
[trio basic from introduction to mastery tutorial 20] trio calculates the arc center and radius through three points of spatial arc
动力电池UL2580测试项目包括哪些
H264 (I) i/p/b frame gop/idr/ and other parameters
Talk about the function of magnetic beads in circuits
Management and use of DokuWiki (supplementary)
实例009:暂停一秒输出
Shape template matching based on Halcon learning [vi] find_ mirror_ dies. Hdev routine
C WinForm [get file path -- traverse folder pictures] - practical exercise 6
STM32 single chip microcomputer - external interrupt
Google sitemap files for rails Projects - Google sitemap files for rails projects
Class of color image processing based on Halcon learning_ ndim_ norm. hdev
C WinForm [change the position of the form after running] - Practical Exercise 4
Wifi-802.11 negotiation rate table
如何写Cover Letter?
Hardware and software solution of FPGA key chattering elimination
How to copy formatted notepad++ text?