图形展示:
代码实现:
# 将分数从高到低进行排序,score1 = [66,45,50,35,60,23]print('原始数据:',score1)for i in range(len(score1)-1): # 轮数 0,1,2,3,4,5 for j in range(len(score1)-i-1): # 控制次数 if score1[j] < score1[j+1]: # 比较2个相邻的数大小 score1[j],score1[j+1] = score1[j+1],score1[j] print('第 {} 轮: '.format(i+1),score1)运行结果如下图:
| 留言与评论(共有 0 条评论) “” |