我正在制作一个计划生成器,每个团队都与其他团队进行比赛。我的数据库表和我需要的输出如下,
到目前为止我尝试过的是
<%
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>
<%}%>
检索团队数量和要播放的匹配数量。请帮帮我。
答案 0 :(得分:1)
这是一个可能的解决方案:
<%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算法。