代码拉取完成,页面将自动刷新
""""
可能我想错了,没有多余时间了,
我把这道题想成了字符串z字变换的题型了
"""
def square(n,m):
lst = [[0 for i in range(m)] for _ in range(n)]
cols = 0
rows = 0
targe = True
count = 0
ll = n * m
for i in range(1,ll+1):
if cols==n and (rows+1)%2==1:
cols -= 1
elif cols == 0 and (rows+1)%2==0:
cols += 1
if 0<=cols <= n - 1 and rows <= m-1:
if count == n:
rows += 1
if targe:
targe = False
else:
targe = True
count = 0
if targe:
lst[cols][rows] = i
cols += 1
else:
lst[cols][rows] = i
cols -= 1
count += 1
print(lst)
if __name__ == '__main__':
square(3,5)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。