正文
字符
import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
s = int(input())
for i in range(s):
print('+'*s)
数字矩阵
import math
import sys
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
x, y = [int(i) for i in input().split()]
# 定义相差near
near = 0
for i in range(1, x + 1):
j = i
near += 1
for flag in range(y):
if flag == y - 1:
print(j, end="")
break
# 输出从1开始的相差near
print(j, end=" ")
j += near
print()
另外还有一种不错的方法(作者:Thiago0609)
import math
import sys
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
x, y = [int(i) for i in input().split()]
l = []
for i in range(1, x + 1):
l.append(i)
for i in range(1, y + 1):
print(" ".join([str(i * j) for j in l]))
有个规律,每个元素的值都是行索引*列索引
对每行遍历即可
写在最后
欢迎技术类的问题到这里提出,我会逐个解答