解题思路:利用Python列表特性解题
注意事项:sort()的项是按tuple类型中的元素从前到后依次进行的
参考代码:
n = int(input())
lst = []
lst_sum = []
lst_index = [i + 1 for i in range(n)]
for i in range(n) :
lst.append(list(map(int, input().split())))
lst_sum.append(sum(lst[i]))
lst = list(zip(lst_sum, lst))
for i in range(n) :
lst[i] = list(lst[i])
lst[i].append(lst_index[i])
for i in range(n) :
lst[i] = tuple(lst[i])
lst.sort(reverse=True)
lst = lst[:5]
for i in range(5) :
if i <= 3 :
if lst[i][0] == lst[i + 1][0] and lst[i][1][0] == lst[i + 1][1][0] and lst[i][2] > lst[i+1][2]:
lst[i], lst[i + 1] = lst[i + 1], lst[i]
print('{} {}'.format(lst[i][2], lst[i][0]))
0.0分
1 人评分
2005年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:648 |
简单的a+b (C语言代码)浏览:817 |
printf基础练习2 (C语言代码)浏览:747 |
【亲和数】 (C语言代码)浏览:600 |
DNA (C语言代码)浏览:741 |
C语言程序设计教程(第三版)课后习题12.6 (C语言代码)浏览:662 |
C语言训练-自守数问题 (C语言代码)浏览:748 |
快速排序算法1浏览:884 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:456 |
判定字符位置 (C++代码)浏览:676 |