2020年11月17日
摘要: 集合是由一组无序且唯一(即不能重复)的项组成的。 创建集合类 class Set { constructor() { this.items = {}; } //首先要实现的是 has(element)方法,因为它会被 add、delete 等其他方法调用。如果元素在集合中,返回 true,否则返回 阅读全文
posted @ 2020-11-17 14:35 chen_coder 阅读(108) 评论(0) 推荐(0)
摘要: 756.蛇形矩阵 #题目:输入两个整数n和m,输出一个n行m列的矩阵,将数字 1 到 n*m 按照回字蛇形填充至矩阵中。 #输入: #3 3 #输出: # 1 2 3 # 8 9 4 # 7 6 5 n, m = map(int, input().strip().split()) # 以垂直向下为x 阅读全文
posted @ 2020-11-17 11:02 chen_coder 阅读(253) 评论(0) 推荐(0)
摘要: 需求:想通过python生成m行n列的矩阵 方式1:(有问题) data = [[0]*3]*4 #4行3列 print(data) #[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]] 赋值 data[0][0] = 1 print(data) #[[1, 0 阅读全文
posted @ 2020-11-17 09:53 chen_coder 阅读(1907) 评论(0) 推荐(1)