소스 정리하다가 옛날에 축구관련 사이트 작업한게 있었는데 있길래 한번 올려봅니다.
작업당시에 기존 존재하는 소스가 있나 싶어서 찾아봤는데 없는거 같길래 만들었어요~
자주 쓰이는 경기방식중에는
1. 리그방식
2. 링크방식
3. 토너먼트방식
이렇게 존재하는데요~
아래 소스는 리그방식 생성소스입니다.
1개의 라운드 안에 중복된 팀이 경기가 잡히지 않게
기본 로직만 있는거라서 도움이 될지 모르겠네요..
<?
////////////////////////////////////////////
$jocnt = 4; // 조 갯수
$roundloopfcnt = 1; // 같은 라운드 반복 횟수:기본값1(국내프로축구에서 자주 쓰임)
$teamcnt = 12; // 조당 팀갯수
////////////////////////////////////////////
for($j=0; $j<$jocnt; $j++){
// 1개 조내의 경기수(라운드 반복 제외)
$if_jogamecnt = 0;
for($i=1; $i<$teamcnt; $i++){
$if_jogamecnt = $if_jogamecnt + $i;
}
// 팀별코드 부여
for($i=0; $i<$teamcnt; $i++){
$if_teamcode[$i] = $i+1;
}
// 1개 조내의 1개 라운내의 경기수
$if_roundincnt = floor($teamcnt/2);
// 라운드 수
$if_roundcnt = ($if_jogamecnt / $if_roundincnt) * $roundloopfcnt;
if(!($teamcnt%2)){ // 짝수
$if_teamcode_0 = array_shift($if_teamcode);
sort($if_teamcode);
}else{
$if_teamcode_temp = $if_teamcode;
$temp1 = array_pop($if_teamcode);
for($ti=1; $ti<=count($if_teamcode); $ti++){
$if_teamcode_temp[$ti] = $if_teamcode[$ti-1];
}
$if_teamcode_temp[0] = $temp1;
ksort($if_teamcode_temp);
$if_teamcode = $if_teamcode_temp;
}
$if_teamcode2 = $if_teamcode;
for($c=0; $c<$if_roundcnt; $c++){
for($i=0; $i<$if_roundincnt; $i++){
$if_gamecnt++;
if(!($teamcnt%2)){
if($i==0){
$team1 = $if_teamcode_0;
$team2 = $if_teamcode2[0];
}else{
$team1 = $if_teamcode2[$i];
$team2 = $if_teamcode2[count($if_teamcode2)-($i)];
}
}else{
$team1 = $if_teamcode2[$i+1];
$team2 = $if_teamcode2[count($if_teamcode2)-($i+1)];
}
echo "No. ".$if_gamecnt." || ".($j+1)." 조 | ".($c+1)." 라운드 | ".$team1."팀 vs ".$team2."팀<br>";
}
$temp1 = array_pop($if_teamcode2);
for($ti=1; $ti<=count($if_teamcode2); $ti++){
$if_teamcode3[$ti] = $if_teamcode2[$ti-1];
}
$if_teamcode3[0] = $temp1;
ksort($if_teamcode3);
$if_teamcode2 = $if_teamcode3;
}
}
?>
작업당시에 기존 존재하는 소스가 있나 싶어서 찾아봤는데 없는거 같길래 만들었어요~
자주 쓰이는 경기방식중에는
1. 리그방식
2. 링크방식
3. 토너먼트방식
이렇게 존재하는데요~
아래 소스는 리그방식 생성소스입니다.
1개의 라운드 안에 중복된 팀이 경기가 잡히지 않게
기본 로직만 있는거라서 도움이 될지 모르겠네요..
<?
////////////////////////////////////////////
$jocnt = 4; // 조 갯수
$roundloopfcnt = 1; // 같은 라운드 반복 횟수:기본값1(국내프로축구에서 자주 쓰임)
$teamcnt = 12; // 조당 팀갯수
////////////////////////////////////////////
for($j=0; $j<$jocnt; $j++){
// 1개 조내의 경기수(라운드 반복 제외)
$if_jogamecnt = 0;
for($i=1; $i<$teamcnt; $i++){
$if_jogamecnt = $if_jogamecnt + $i;
}
// 팀별코드 부여
for($i=0; $i<$teamcnt; $i++){
$if_teamcode[$i] = $i+1;
}
// 1개 조내의 1개 라운내의 경기수
$if_roundincnt = floor($teamcnt/2);
// 라운드 수
$if_roundcnt = ($if_jogamecnt / $if_roundincnt) * $roundloopfcnt;
if(!($teamcnt%2)){ // 짝수
$if_teamcode_0 = array_shift($if_teamcode);
sort($if_teamcode);
}else{
$if_teamcode_temp = $if_teamcode;
$temp1 = array_pop($if_teamcode);
for($ti=1; $ti<=count($if_teamcode); $ti++){
$if_teamcode_temp[$ti] = $if_teamcode[$ti-1];
}
$if_teamcode_temp[0] = $temp1;
ksort($if_teamcode_temp);
$if_teamcode = $if_teamcode_temp;
}
$if_teamcode2 = $if_teamcode;
for($c=0; $c<$if_roundcnt; $c++){
for($i=0; $i<$if_roundincnt; $i++){
$if_gamecnt++;
if(!($teamcnt%2)){
if($i==0){
$team1 = $if_teamcode_0;
$team2 = $if_teamcode2[0];
}else{
$team1 = $if_teamcode2[$i];
$team2 = $if_teamcode2[count($if_teamcode2)-($i)];
}
}else{
$team1 = $if_teamcode2[$i+1];
$team2 = $if_teamcode2[count($if_teamcode2)-($i+1)];
}
echo "No. ".$if_gamecnt." || ".($j+1)." 조 | ".($c+1)." 라운드 | ".$team1."팀 vs ".$team2."팀<br>";
}
$temp1 = array_pop($if_teamcode2);
for($ti=1; $ti<=count($if_teamcode2); $ti++){
$if_teamcode3[$ti] = $if_teamcode2[$ti-1];
}
$if_teamcode3[0] = $temp1;
ksort($if_teamcode3);
$if_teamcode2 = $if_teamcode3;
}
}
?>
[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8230 | 9년 전 | 73 | ||
| 8229 | 9년 전 | 73 | ||
| 8228 |
커네드커네드
|
9년 전 | 114 | |
| 8227 | 9년 전 | 124 | ||
| 8226 | 9년 전 | 163 | ||
| 8225 | 9년 전 | 150 | ||
| 8224 | 9년 전 | 147 | ||
| 8223 | 9년 전 | 114 | ||
| 8222 |
|
9년 전 | 187 | |
| 8221 | 9년 전 | 91 | ||
| 8220 | 9년 전 | 102 | ||
| 8219 | 9년 전 | 100 | ||
| 8218 | 9년 전 | 140 | ||
| 8217 |
star3840
|
9년 전 | 114 | |
| 8216 | 9년 전 | 162 | ||
| 8215 | 9년 전 | 114 | ||
| 8214 | 9년 전 | 228 | ||
| 8213 | 9년 전 | 161 | ||
| 8212 | 9년 전 | 82 | ||
| 8211 | 9년 전 | 245 | ||
| 8210 | 9년 전 | 245 | ||
| 8209 | 9년 전 | 337 | ||
| 8208 | 9년 전 | 217 | ||
| 8207 | 9년 전 | 228 | ||
| 8206 |
|
9년 전 | 190 | |
| 8205 | 9년 전 | 173 | ||
| 8204 | 9년 전 | 132 | ||
| 8203 | 9년 전 | 233 | ||
| 8202 | 9년 전 | 144 | ||
| 8201 | 9년 전 | 182 | ||
| 8200 | 9년 전 | 164 | ||
| 8199 | 9년 전 | 213 | ||
| 8198 | 9년 전 | 178 | ||
| 8197 | 9년 전 | 167 | ||
| 8196 | 9년 전 | 556 | ||
| 8195 | 9년 전 | 157 | ||
| 8194 | 9년 전 | 283 | ||
| 8193 | 9년 전 | 155 | ||
| 8192 | 9년 전 | 190 | ||
| 8191 | 9년 전 | 143 | ||
| 8190 | 9년 전 | 127 | ||
| 8189 | 9년 전 | 192 | ||
| 8188 | 9년 전 | 129 | ||
| 8187 | 9년 전 | 141 | ||
| 8186 | 9년 전 | 141 | ||
| 8185 | 9년 전 | 313 | ||
| 8184 | 9년 전 | 108 | ||
| 8183 | 9년 전 | 324 | ||
| 8182 | 9년 전 | 166 | ||
| 8181 | 9년 전 | 134 | ||
| 8180 | 9년 전 | 693 | ||
| 8179 | 9년 전 | 488 | ||
| 8178 | 9년 전 | 310 | ||
| 8177 |
kiplayer
|
9년 전 | 320 | |
| 8176 | 9년 전 | 355 | ||
| 8175 | 9년 전 | 220 | ||
| 8174 | 9년 전 | 245 | ||
| 8173 | 9년 전 | 344 | ||
| 8172 | 9년 전 | 196 | ||
| 8171 | 9년 전 | 184 | ||
| 8170 | 9년 전 | 298 | ||
| 8169 |
커네드커네드
|
9년 전 | 260 | |
| 8168 | 9년 전 | 322 | ||
| 8167 | 9년 전 | 322 | ||
| 8166 | 9년 전 | 237 | ||
| 8165 | 9년 전 | 166 | ||
| 8164 | 9년 전 | 304 | ||
| 8163 | 9년 전 | 288 | ||
| 8162 | 9년 전 | 302 | ||
| 8161 | 9년 전 | 297 | ||
| 8160 |
|
9년 전 | 490 | |
| 8159 | 9년 전 | 428 | ||
| 8158 | 9년 전 | 253 | ||
| 8157 | 9년 전 | 381 | ||
| 8156 | 9년 전 | 279 | ||
| 8155 | 9년 전 | 251 | ||
| 8154 |
00년생용띠
|
9년 전 | 599 | |
| 8153 | 9년 전 | 234 | ||
| 8152 |
|
9년 전 | 409 | |
| 8151 | 9년 전 | 409 | ||
| 8150 | 9년 전 | 499 | ||
| 8149 |
Jangfolk
|
9년 전 | 350 | |
| 8148 | 9년 전 | 170 | ||
| 8147 | 9년 전 | 373 | ||
| 8146 | 9년 전 | 436 | ||
| 8145 | 9년 전 | 379 | ||
| 8144 | 9년 전 | 348 | ||
| 8143 | 9년 전 | 194 | ||
| 8142 | 9년 전 | 426 | ||
| 8141 | 9년 전 | 383 | ||
| 8140 | 9년 전 | 929 | ||
| 8139 | 9년 전 | 262 | ||
| 8138 |
전갈자리남자
|
9년 전 | 388 | |
| 8137 | 9년 전 | 397 | ||
| 8136 | 9년 전 | 745 | ||
| 8135 |
|
9년 전 | 794 | |
| 8134 |
PlayPixel
|
9년 전 | 517 | |
| 8133 |
|
9년 전 | 438 | |
| 8132 | 9년 전 | 449 | ||
| 8131 | 9년 전 | 812 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기