Presentation is loading. Please wait.

Presentation is loading. Please wait.

10107: What is the Median? ★★☆☆☆

Similar presentations


Presentation on theme: "10107: What is the Median? ★★☆☆☆"— Presentation transcript:

1 10107: What is the Median? ★★☆☆☆
題組:Problem Set Archive with Online Judge 題號:10107: What is the Median? 解題者:林家賢 解題日期:2013年5月16日 題意:輸入N個(N<10000)整數X (0<=X<231 ),對每一個輸入,輸出到現在為止已輸入的數的中位數。例如:在{1,3,4,9,11}中4就是中位數。如果有偶數個數字,中位數就是中間的2個數的和除以2(只取整數部分)。例如:在{1,2,3,6,7,8}中{3,6}是位於中間的2個數,所以中位數就是(3+6)/2=4。 

2 題意範例: input: 1 3 4 60 70 50 2 陣列:{1}{1,3}{1,3,4}{1,3,4,60}{1,3,4,60,70} {1,3,4,50,60,70}{1,2,3,4,50,60,70} output: 1 2 3 3 4 27 4 解法: (1)每輸入一個數判斷適當位置利用insertion sort插入 (2)判斷是奇數還是偶數,奇數的話印出中間的數,偶數則找出中間的兩個數後,相加除以二印出答案。 解法範例:無 討論:無


Download ppt "10107: What is the Median? ★★☆☆☆"

Similar presentations


Ads by Google