소스 정리하다가 옛날에 축구관련 사이트 작업한게 있었는데 있길래 한번 올려봅니다.
작업당시에 기존 존재하는 소스가 있나 싶어서 찾아봤는데 없는거 같길래 만들었어요~
자주 쓰이는 경기방식중에는
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에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7830 | 10년 전 | 454 | ||
| 7829 |
|
10년 전 | 640 | |
| 7828 | 10년 전 | 563 | ||
| 7827 | 10년 전 | 458 | ||
| 7826 | 10년 전 | 472 | ||
| 7825 | 10년 전 | 516 | ||
| 7824 | 10년 전 | 477 | ||
| 7823 | 10년 전 | 421 | ||
| 7822 | 10년 전 | 394 | ||
| 7821 | 10년 전 | 339 | ||
| 7820 | 10년 전 | 363 | ||
| 7819 |
|
10년 전 | 765 | |
| 7818 | 10년 전 | 416 | ||
| 7817 | 10년 전 | 580 | ||
| 7816 | 10년 전 | 437 | ||
| 7815 | 10년 전 | 631 | ||
| 7814 | 10년 전 | 470 | ||
| 7813 | 10년 전 | 426 | ||
| 7812 | 10년 전 | 437 | ||
| 7811 | 10년 전 | 416 | ||
| 7810 | 10년 전 | 612 | ||
| 7809 | 10년 전 | 543 | ||
| 7808 | 10년 전 | 419 | ||
| 7807 | 10년 전 | 437 | ||
| 7806 |
프로그래머7
|
10년 전 | 1361 | |
| 7805 | 10년 전 | 1301 | ||
| 7804 |
zahir1312
|
10년 전 | 802 | |
| 7803 |
|
10년 전 | 1401 | |
| 7802 | 10년 전 | 496 | ||
| 7801 | 10년 전 | 882 | ||
| 7800 | 10년 전 | 1109 | ||
| 7799 | 10년 전 | 587 | ||
| 7798 | 10년 전 | 538 | ||
| 7797 | 10년 전 | 557 | ||
| 7796 | 10년 전 | 389 | ||
| 7795 | 10년 전 | 539 | ||
| 7794 | 10년 전 | 585 | ||
| 7793 | 10년 전 | 1084 | ||
| 7792 | 10년 전 | 509 | ||
| 7791 | 10년 전 | 594 | ||
| 7790 | 10년 전 | 528 | ||
| 7789 |
fbastore
|
10년 전 | 1479 | |
| 7788 | 10년 전 | 582 | ||
| 7787 | 10년 전 | 437 | ||
| 7786 | 10년 전 | 647 | ||
| 7785 | 10년 전 | 620 | ||
| 7784 | 10년 전 | 679 | ||
| 7783 | 10년 전 | 499 | ||
| 7782 | 10년 전 | 525 | ||
| 7781 | 10년 전 | 931 | ||
| 7780 | 10년 전 | 844 | ||
| 7779 | 10년 전 | 797 | ||
| 7778 | 10년 전 | 383 | ||
| 7777 | 10년 전 | 496 | ||
| 7776 | 10년 전 | 490 | ||
| 7775 | 10년 전 | 430 | ||
| 7774 | 10년 전 | 643 | ||
| 7773 | 10년 전 | 399 | ||
| 7772 | 10년 전 | 771 | ||
| 7771 | 10년 전 | 423 | ||
| 7770 | 10년 전 | 670 | ||
| 7769 | 10년 전 | 427 | ||
| 7768 | 10년 전 | 649 | ||
| 7767 | 10년 전 | 1204 | ||
| 7766 | 10년 전 | 529 | ||
| 7765 | 10년 전 | 585 | ||
| 7764 |
잘살아보자
|
10년 전 | 433 | |
| 7763 |
|
10년 전 | 1492 | |
| 7762 |
Tosea
|
10년 전 | 1086 | |
| 7761 | 10년 전 | 685 | ||
| 7760 |
잘살아보자
|
10년 전 | 734 | |
| 7759 |
잘살아보자
|
10년 전 | 571 | |
| 7758 |
잘살아보자
|
10년 전 | 629 | |
| 7757 | 10년 전 | 1274 | ||
| 7756 |
ITBANK
|
10년 전 | 1284 | |
| 7755 | 10년 전 | 1941 | ||
| 7754 | 10년 전 | 1097 | ||
| 7753 | 10년 전 | 915 | ||
| 7752 | 10년 전 | 1417 | ||
| 7751 |
잘살아보자
|
10년 전 | 572 | |
| 7750 |
잘살아보자
|
10년 전 | 504 | |
| 7749 |
잘살아보자
|
10년 전 | 521 | |
| 7748 |
잘살아보자
|
10년 전 | 542 | |
| 7747 |
잘살아보자
|
10년 전 | 621 | |
| 7746 |
잘살아보자
|
10년 전 | 696 | |
| 7745 |
잘살아보자
|
10년 전 | 941 | |
| 7744 |
잘살아보자
|
10년 전 | 438 | |
| 7743 | 10년 전 | 966 | ||
| 7742 |
starbros
|
10년 전 | 860 | |
| 7741 |
잘살아보자
|
10년 전 | 700 | |
| 7740 |
잘살아보자
|
10년 전 | 589 | |
| 7739 |
잘살아보자
|
10년 전 | 485 | |
| 7738 |
잘살아보자
|
10년 전 | 560 | |
| 7737 |
잘살아보자
|
10년 전 | 539 | |
| 7736 |
잘살아보자
|
10년 전 | 559 | |
| 7735 |
잘살아보자
|
10년 전 | 892 | |
| 7734 |
잘살아보자
|
10년 전 | 451 | |
| 7733 |
잘살아보자
|
10년 전 | 563 | |
| 7732 |
잘살아보자
|
10년 전 | 727 | |
| 7731 |
잘살아보자
|
10년 전 | 647 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기