Algorithm 匹配调度生成器算法

Algorithm 匹配调度生成器算法,algorithm,jsp,scheduling,Algorithm,Jsp,Scheduling,我正在开发一个时间表生成器,每个团队都会与其他团队进行一场比赛。我的数据库表和我需要的输出如下所示, 到目前为止,我所尝试的是 <% ResultSet rsteams = clmmodel_database.selectQuery("select count(ct.teamid) as teamcount, teamid,teamname from clm_team ct"); while(rsteams.next()){ int teamcount =

我正在开发一个时间表生成器,每个团队都会与其他团队进行一场比赛。我的数据库表和我需要的输出如下所示,

到目前为止,我所尝试的是

 <%
    ResultSet rsteams = clmmodel_database.selectQuery("select count(ct.teamid) as teamcount, teamid,teamname from clm_team ct");
    while(rsteams.next()){
       int teamcount = rsteams.getInt("teamcount"); 
       int n = teamcount - 1;
       int numofmatches  = n*(n+1)/2; 
    %>
    <h1>Team Count = <%out.print(teamcount);%></h1>
    <h1>Number of Matches = <%out.print(numofmatches);%></h1>
    <table>
    <%for(int i =0;i<n;i++){%>
    <tr>
      //Here I need to display the matches row by row  
    </tr>
    <%}%>
    </table>

    <%}%>

团队计数=
匹配数=

下面是一个可能的解决方案:

<%for(int i =0; i< n - 1; i++){%>
  <%for(int j = i + 1; i<n; j++){%>
    <tr>
      //Here you can display team i and team j
    </tr>
  <%}%> 
<%}%>


如何一次从两行中检索两个值?由于两个团队ID和名称位于两行中,因此可以使用ResultSet.absolut方法(索引从1开始)