1 Star 0 Fork 0

libow-python / python_leetcode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
juzheng.py 675 Bytes
一键复制 编辑 原始数据 按行查看 历史
libow-python 提交于 2021-12-30 18:26 . mianshi
""""
可能我想错了,没有多余时间了,
我把这道题想成了字符串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)
1
https://gitee.com/libow-python/python_leetcode.git
git@gitee.com:libow-python/python_leetcode.git
libow-python
python_leetcode
python_leetcode
master

搜索帮助