链接: https://pan.baidu.com/s/1mkche9y 密码: cbyb
## 13 两重循环习题1
#下三角
j = 1 # j 代表行号, i代表列号
while j < 10:
i = 1
print(j, "->", end=' ')
while i < 10:
if j >= i:
print(j * i, end=' ')
i += 1
print(" ")
j += 1
#右上三角
j = 1 # j 代表行号, i代表列号
while j < 10:
i = 1
print(j, "->", end=' ')
while i < 10:
if j <= i:
print(j * i, end=' ')
else:
print(" ", end='')
i += 1
print(" ")
j += 1
#左上三角
j = 1 # j 代表行号, i代表列号
while j < 10:
i = 1
print(j, "->", end=' ')
while i < 10:
if j + i <= 10:
print(j * i, end=' ')
i += 1
print(" ")
j += 1
#对角线
j = 1 # j 代表行号, i代表列号
while j < 10:
i = 1
print(j, "->", end=' ')
while i < 10:
if j == i:
print(j * i, end=' ')
else:
print(" ", end='')
i += 1
print(" ")
j += 1