Commit 6430bc1b by BellCodeEditor

auto save

parent f7095699
......@@ -22,18 +22,19 @@ class Hero(object):
exit()
class Player(Hero):
def __init__(self, name):
def __init__(self, name,hero_type):
#继承父类
super().__init__(name)
self.hp = 200
self.attack = 50
self.hero_type=hero_type
print("角色"+self.name+"创建成功,它的英雄类型是:",self.hero_type)
print(self.name+"等级、血量、攻击力分别是:",self.level,self.hp,self.attack)
# yase = Hero("垭瑟")
# houyi= Hero("后羿")
# yase.combat(houyi)
player=Player("后羿")
print(player.hp)
print(player.attack)
print(player.level)
\ No newline at end of file
#创建对象
player=Player("后羿","射手")
class Dog:
def __init__(self,name):
self.tui=4
self.eyes=2
self.skin="white"
self.name=name
class Husky(Dog):
def __init__(self,name):
super().__init__(name)
self.skin="black"
xiaohei=Husky("小黑")
print(xiaohei.skin)
\ No newline at end of file
list=[16,25,39,27,12,8,45,63]
gap=len(list)//2
while gap>0:
for i in range(gap,len(list)):
for j in range(i,0,-gap):
if list[j]<list[j-gap]:
list[j],list[j-gap]=list[j-gap],list[j]
gap=gap//2
print(list)
\ No newline at end of file
list=[16,25,39,27,12,8,45,63]
gap=len(list)//2
while gap>0:
# for i in range(gap,len(list)):
i=gap
while i<len(list):
# for j in range(i,0,-gap):
j=i
while j>0:
if list[j]<list[j-gap]:
list[j],list[j-gap]=list[j-gap],list[j]
j=j-gap
else:
break
i += 1
gap=gap//2
print(list)
#插入排序
times = 0
list=[16,25,39,27,12,8,45,63]
for i in range(1,len(list)):#插入的位置
for j in range(i,0,-1):#从插入位置逐个与前面的值进行比较
times +=1
if list[j]<list[j-1]:
list[j],list[j-1]=list[j-1],list[j]
print(list)
print(times)
data=[16,25,39,27,12,8,45,63]
#增量
gap=len(data)//2
times=0
while gap>0:
# for i in range(gap,len(data)):#插入的位置
i=gap
while i<len(data):
# for j in range(i,0,-gap):#从插入位置逐个与前面的值进行比较
j=i
while j>0:
times += 1
if data[j]<data[j-gap]:
data[j],data[j-gap]=data[j-gap],data[j]
j -= gap
else:
break
i += 1
gap=gap//2
print(times)
print(data)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment