小编Ali*_*ela的帖子

双循环赛

我正在基于循环调度算法开发java中的运动项目.对于n支队伍,我希望用n/2场比赛产生2(n-1)轮.也就是说每支球队都必须在一轮比赛中进行比赛,每两支球队会两次,一次一次,一次回家.我设法实现了algoritm,除了home/away部分.我能够产生回合,但是在下半场不能"交换"球队,所以他们可以在主场和主场比赛.

这是我到目前为止:

import java.util.Arrays;
import java.util.Scanner;

public class sports {

public static void main(String[] args) {

    //obtain the number of teams from user input
    Scanner input = new Scanner(System.in);
    System.out.print("How many teams should the fixture table have?");

    int teams;
    teams = input.nextInt();


    // Generate the schedule using round robin algorithm.
    int totalRounds = (teams - 1)*2;
    int matchesPerRound = teams / 2;
    String[][] rounds = new String[totalRounds][matchesPerRound];

    for (int round = 0; round < totalRounds; round++) {
        for (int match …
Run Code Online (Sandbox Code Playgroud)

java schedule round-robin

5
推荐指数
1
解决办法
3714
查看次数

标签 统计

java ×1

round-robin ×1

schedule ×1