当前位置:网站首页>实例008:九九乘法表
实例008:九九乘法表
2022-07-05 08:16:00 【懒笑翻】
实例008:九九乘法表
题目:输出 9*9 乘法口诀表。
程序分析:分行与列考虑,共9行9列,i控制行,j控制列。
# 第i行有i列,range是半闭半开区间因此range要到i+1 # 为输出更美观,对于相乘的结果设置为%-2d即占2位,-表示左对齐,不加-就是默认右对齐 end=''即输出后不换行
代码如下:
for i in range(1, 10):
for j in range(1, i + 1): # 第i行有i列,range是半闭半开区间因此range要到i+1
print('%d*%d=%-2d ' % (i, j, i * j), end='') # 为输出更美观,对于相乘的结果设置为%-2d即占2位,-表示左对齐,不加-就是默认右对齐 end=''即输出后不换行
print() #换行
输出结果如下:
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
边栏推荐
- Zero length array in GNU C
- QEMU demo makefile analysis
- Correlation based template matching based on Halcon learning [II] find_ ncc_ model_ defocused_ precision. hdev
- 亿学学堂给的证券账户安不安全?哪里可以开户
- PMSM dead time compensation
- Bootloader implementation of PIC MCU
- C#,数值计算(Numerical Recipes in C#),线性代数方程的求解,LU分解(LU Decomposition)源程序
- Shape template matching based on Halcon learning [viii] PM_ multiple_ models. Hdev routine
- Shape template matching based on Halcon learning [v] find_ cocoa_ packages_ max_ deformation. Hdev routine
- NTC thermistor application - temperature measurement
猜你喜欢
Network communication process
Arduino uses nrf24l01+ communication
[tutorial 15 of trio basic from introduction to proficiency] trio free serial communication
Briefly talk about the identification protocol of mobile port -bc1.2
Stablq of linked list
How to select conductive slip ring
Shell脚本基本语法
[paper reading] the latest transfer ability in deep learning: a survey in 2022
Shape template matching based on Halcon learning [VII] reuse_ model. Hdev routine
Solutions to compilation warnings in Quartus II
随机推荐
WiFi wpa_ Detailed description of supplicant hostpad interface
Vofa+ software usage record
General makefile (I) single C language compilation template
【云原生 | 从零开始学Kubernetes】三、Kubernetes集群管理工具kubectl
Measurement fitting based on Halcon learning [i] fuse Hdev routine
Tailq of linked list
Detailed summary of FIO test hard disk performance parameters and examples (with source code)
[trio basic tutorial 17 from getting started to mastering] set up and connect the trio motion controller and input the activation code
Basic information commands and functions of kernel development
Embedded composition and route
Wifi-802.11 negotiation rate table
Bootloader implementation of PIC MCU
Negative pressure generation of buck-boost circuit
Step motor generates S-curve upper computer
On boost circuit
Development tools -- gcc compiler usage
Programming knowledge -- assembly knowledge
亿学学堂给的证券账户安不安全?哪里可以开户
C, Numerical Recipes in C, solution of linear algebraic equations, LU decomposition source program
UEFI development learning 5 - simple use of protocol