algorithm - 比赛时间表生成器算法

标签 algorithm jsp scheduling

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

到目前为止我尝试过的是

 <%
    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>
  <%}%> 
<%}%>

我也建议你看看these算法。

关于algorithm - 比赛时间表生成器算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19724039/

相关文章:

java - MergeSort 算法 - java

php - 生成单场淘汰赛

java - 在apache tomcat中使用文件上传控件上传多个文件

java - 从数据库表中检索数据并用html将其显示在表中

linux - 为什么不能直接从硬件中断调用 schedule()?

c++ - 一道面试题

arrays - 无法实现数组的就地排列工作

java - 重构 JSP 中的 EL 表达式

java - 有没有更优雅的方式来启动基于列表的线程?

linux-kernel - rcu_preempt self 检测到 CPU { 0} 上的停顿