python
killer__
这个作者很懒,什么都没留下…
展开
-
python练手
练习实例3 题目:一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少? 程序分析: 假设该数为 x。 1、则:x + 100 = n2, x + 100 + 168 = m2 2、计算等式:m2 - n2 = (m + n)(m - n) = 168 3、设置: m + n = i,m - n = j,i * j =168,i 和 j 至少一个是偶数 4、可得...原创 2019-04-08 18:45:00 · 132 阅读 · 0 评论 -
Python实现AVL树
class Node: def __init__(self,key): self.key=key self.left=None self.right=None self.height=0 class AVLTree: def __init__(self): self.root=None def ...原创 2019-05-07 17:02:55 · 1350 阅读 · 2 评论 -
Python小白的零碎记录
3.7往后iterable 、iterator包都包含在collections.abc中了,记录一下 from collections.abc import Iterable,Iterator print(isinstance((),Iterable)) int进制转换:hex() int() oct() bin() ...原创 2019-06-06 15:31:04 · 166 阅读 · 0 评论 -
找数组中重复的数字
def func(tmp): for j in range(len(tmp)): i=j while tmp[i]!=i: if tmp[tmp[i]]==tmp[i]: return tmp[i] else: x=tmp[i] tmp[i],tmp[x]=tm...原创 2019-09-11 23:52:04 · 97 阅读 · 0 评论