# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
def quick_sort(lists,i,j):
if i >= j:
return list
pivot = lists[i]
low = i
high = j
while i < j:
while i < j and lists[j] >= pivot:
j -= 1
lists[i]=lists[j]
while i < j and lists[i] <=pivot:
i += 1
lists[j]=lists[i]
lists[j] = pivot
quick_sort(lists,low,i-1)
quick_sort(lists,i+1,high)
return lists
f = open("C:/Users/11379/Desktop/scores.txt","r")
data = []
name = {}
lines = f.readlines()
for line in lines:
line = line.split(' ')
data.append(line[-1])
name[line[-1]] = line[0]
good,bad = [],[]
data = quick_sort(data, 0, len(data)-1)
for score in reversed(data):
if int(score) >= 60:
good.append(name[score]+' '+score)
else:
bad.append(name[score]+' '+score)
print(good)
print(bad)
成绩统计排序
最新推荐文章于 2024-09-05 20:15:59 发布