牛津大學編程思維挑戰賽(The Oxford University Computing Challenge-OUCC)根據難度分為初級、中級、高級和精英級四個等級,分別對應小學,初中和高中。
該學術活動新賽季報名時間已公布,報名通道及學術活動真題開放中!
學術活動時間:
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字典的應用
參考代碼:

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

以上就是關于【牛津大學編程挑戰賽(OUCC)-報名-真題2】的解答,如需了解學校/賽事/課程動態,可至翰林教育官網獲取更多信息。
往期文章閱讀推薦:
【北美線下活動】麻省波士頓/洛杉磯/爾灣!50+稀缺錄取案例揭秘升學密碼!
9月20日【北美巡講 · 洛杉磯站】預約報名中!加州學生專屬的ISEF晉級捷徑首次拆解!特邀ISEF總決賽評委親臨現場!

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