亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

答案:利用冒泡排序完成?。?!

name = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']

score = [89, 72, 88, 79, 99]


for i in range(len(score) - 1) :

? ? for j in range(len(score) - i - 1) :

? ? ? ? if score[j] < score[j + 1] :?

? ? ? ? ? ? score[j], score[j + 1] =? score[j + 1] ,score[j]

? ? ? ? ? ? name[j], name[j + 1] =? name[j + 1] ,name[j]

? ? ? ? ? ??

print(name)



正在回答

3 回答

感覺各位都想復雜了,各種秀,這個案例只是展示list的元素替換而已

0 回復 有任何疑惑可以回復我~

# Enter a code

# coding:utf-8

names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']

scores = [89, 72, 88, 79, 99]


templateNames = []

templateScores = [89, 72, 88, 79, 99]


scores.sort(reverse=True)

print("降序排列后的成績:" + str(scores))


index_Score = 0

index_TemplateScore = 0

for score in scores:

? ? index_TemplateScore = 0


? ? for templateScore in templateScores:

? ? ? ? if score == templateScore:

? ? ? ? ? ? templateNames.append(names[index_TemplateScore])

? ? ? ? index_TemplateScore += 1


print("排列后的名字:" + str(templateNames))


1 回復 有任何疑惑可以回復我~

s1 = set([1, 2, 3, 4, 5])
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
print(s1 & s2)

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
Python3 入門教程(新版)
  • 參與學習       162675    人
  • 解答問題       1121    個

python3入門教程,讓你快速入門并能編寫簡單的Python程序

進入課程

答案:利用冒泡排序完成?。?!

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號