Commit 64043b87 by BellCodeEditor

save project

parent fecd419e
Showing with 33 additions and 10 deletions
......@@ -3,17 +3,19 @@
# 请优化刚刚的代码,并增添交互效果,和自动输出最强三人信息的功能~
# 问询处
name=input("请输入你的名字")
power=input("请输入你的臂力")
# 归档处
hero=['赵一',30,'丁二',37,'孙五',52,'王猛',89,'周亮',98,'张宇',100]
for i in range(len(hero)):
if i%2==1 and hero[i]>=int(power):
hero.insert(i-1,name)
hero.insert(i,power)
break
print(hero)
people=input("请问有多少人")
for a in range(int(people)):
name=input("请输入你的名字")
power=input("请输入你的臂力")
for i in range(len(hero)):
if i%2==1 and hero[i]>=int(power):
hero.insert(i-1,name)
hero.insert(i,int(power))
break
print(hero)
......
k=input("请问你要输入的次数") #询问输入次数
people=[] #设置空列表
name=input("请输入你的名字")
power=input("请输入你的年龄")
people.append(name)
people.append(int(power))
print(people)
for a in range(int(k)-1): #设置重复执行次数
name=input("请输入你的名字")
power=input("请输入你的年龄")
for i in range(len(people)):
if i%2==1 and people[i]>=int(power):
people.insert(i-1,name)
people.insert(i,int(power))
break
print(people)
\ 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