牛津大學編程思維挑戰(zhàn)賽(The Oxford University Computing Challenge-OUCC)根據(jù)難度分為初級、中級、高級和精英級四個等級,分別對應小學,初中和高中。
該學術(shù)活動新賽季報名時間已公布,報名通道及學術(shù)活動真題開放中!
學術(shù)活動時間:
2022年5月8日14:00-15:00(60 分鐘)
Sorting Pairs
A set of pairs of integers needs sorting. There are n pairs in the set and the pairs need sorting in ascending order according to the sum of the pair of numbers.
Input format:
An integer,?n, indicating the number of pairs of numbers, followed by up to 20 lines of data, each line consisting of two integers.
Output format:
The sorted pairs of numbers, or the string?sorted?if the set of pairs is already sorted.
Example
Input:
5
0 10
4 10
1 10
3 10
2 10
Output:
0 10
1 10
2 10
3 10
4 10
Constraints:
All numbers are positive integers less than 100.
None of the input data in this task contains pairs of numbers whose sum is the same as any other pair in the same set.
Task:
Write a program that sorts a set of pairs of numbers in ascending order according to the sum of the pair of numbers.
Note: For Java (and similar) programs the grader expects the name of the main class to be: sortingpairs
知識點:
list列表的應用
tuple元組的應用
dict字典的應用
參考代碼:

想要獲取備賽計劃,考前查缺補漏、重點沖刺
歡迎前來掃描二維碼咨詢【免費領取】歷年學術(shù)活動真題及解析!


? 2025. All Rights Reserved. 滬ICP備2023009024號-1