2011-11-17 16 views
0

我們需要做籃球隊分類。在多個項目之間而不是在兩個項目之間分配算法(籃球)?

供參考的程序是在這裏:

D.1 Procedure 
Teams shall be classified according to their win-loss records, namely two (2) points 
for each game won, one (1) point for each game lost (including lost by default) and 
zero (0) points for a game lost by forfeit. 

D.1.1 If there are two (2) teams in the classification with equal points, the result(s) of the 
game(s) between the two (2) teams involved will be used to determine the placing. 

D.1.2 If the points and the goal average in the games between the two (2) teams are still 
the same, the classification will be determined by the goal average of all the games 
played in the group by each team. 

D.1.3 If there are more than two (2) teams in the classification with equal points, a second 
classification will be established, taking into account only the results of the games 
between the involved teams. 

D.1.4 If at any stage of this procedure the number of teams with equal points is reduced 
to only two (2) teams, the procedure in D.1.1 and D.1.2 above will be applied. 

D.1.5 If in the second classification there are still teams with equal points, the goal 
average will be used to determine the placing, taking into account only the results 
of the games between the involved teams. 

D.1.6 If there are still more than two (2) teams with the same goal average, the placing 
will be determined using the goal average from the results of all their games played 
in the group. 

D.1.7 If at any stage of this procedure the number of teams with equal points is reduced 
to a tie still involving more than two (2) teams, the procedure, beginning with D.1.3 
above, is repeated. 

D.1.8 Goal average will always be calculated by division. 

的問題是如何接近D.1.3節,其中說:If there are more than two (2) teams in the classification with equal points, a second classification will be established, taking into account only the results of the games between the involved teams.如何將第二分類模型以及如何根據結果決定他們之間的遊戲?

+1

當只有1.3節重要時,您是否真的需要幾乎逐字地發佈問題? – hugomg

+0

同意,幾乎TLDR'd – Nicolas78

回答

1

對於k個分數相同的團隊,構建一個規模爲k的較小的「聯賽桌」,這個聯盟桌將僅以這些球隊之間的比賽爲基礎填充點數和目標。

在這個較小的表上遞歸地激活排序過程。

如果沒有團隊在2次遞歸調用[團隊完全平等]或完全排名建立時間減少。如果列表包含兩個只有相同點的團隊:則適用二級標準。

-1

您可以使用BogoSort

  1. 將所有團隊存儲在列表中。
  2. 創建一個驗證程序,確定是否按照過程正確排序了List<Team>
  3. 然後你的代碼將如下所示。

    無效的排序(表隊) { 而(!驗證。有效的(球隊)){ 集合 。洗牌(隊); }}

1

你比較可能有強隊之列的參考。即使在調用過程D.1.3的情況下,它也能夠比較這兩個元素。

+0

這似乎是最初的方式,但第二個想法,我認爲你讓自己陷入麻煩:這不是像'使用領域a,如果這是平等使用領域b'的情況 - 而是領域'b'(性能與直接競爭對手)需要根據需求進行計算。每次對該組的成員進行評估或預先計算時,您都必須重新計算。如果你真的有領帶,你只想預先計算它。所以你必須先按照第一條標準進行排序。這讓你在@missno的解決方案,有效 – Nicolas78

+0

正確。您可以將比較結果存儲在比較器中以避免不必要的重新計算,但這基本上是missno的解決方案。這種方法的主要優點是,一旦你編寫比較器,你可以將它傳遞給Collections.sort。 – emory

1

做到這一點,你會怎麼做它在現實生活中:

  1. 排序列表排序後使用的標準清單的團隊,他們比較
  2. ,做通了,看看是否有是3隊以上的任何隊伍。
  3. 每當你找到這樣一組3+的領帶,這次使用解決它不同的設置標準
相關問題