소스 정리하다가 옛날에 축구관련 사이트 작업한게 있었는데 있길래 한번 올려봅니다.
작업당시에 기존 존재하는 소스가 있나 싶어서 찾아봤는데 없는거 같길래 만들었어요~
자주 쓰이는 경기방식중에는
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에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7230 | 11년 전 | 3635 | ||
| 7229 | 11년 전 | 3759 | ||
| 7228 | 11년 전 | 3798 | ||
| 7227 | 11년 전 | 3920 | ||
| 7226 | 11년 전 | 2371 | ||
| 7225 | 11년 전 | 17460 | ||
| 7224 |
AngryDev
|
11년 전 | 1366 | |
| 7223 |
돌아온깡통
|
11년 전 | 1114 | |
| 7222 |
돌아온깡통
|
11년 전 | 1057 | |
| 7221 |
돌아온깡통
|
11년 전 | 888 | |
| 7220 |
돌아온깡통
|
11년 전 | 1009 | |
| 7219 |
돌아온깡통
|
11년 전 | 843 | |
| 7218 |
돌아온깡통
|
11년 전 | 671 | |
| 7217 |
돌아온깡통
|
11년 전 | 1059 | |
| 7216 |
돌아온깡통
|
11년 전 | 799 | |
| 7215 |
돌아온깡통
|
11년 전 | 718 | |
| 7214 |
돌아온깡통
|
11년 전 | 1066 | |
| 7213 |
돌아온깡통
|
11년 전 | 938 | |
| 7212 |
돌아온깡통
|
11년 전 | 722 | |
| 7211 |
돌아온깡통
|
11년 전 | 880 | |
| 7210 |
돌아온깡통
|
11년 전 | 904 | |
| 7209 |
돌아온깡통
|
11년 전 | 895 | |
| 7208 |
돌아온깡통
|
11년 전 | 1014 | |
| 7207 |
돌아온깡통
|
11년 전 | 628 | |
| 7206 |
돌아온깡통
|
11년 전 | 689 | |
| 7205 |
돌아온깡통
|
11년 전 | 874 | |
| 7204 |
돌아온깡통
|
11년 전 | 737 | |
| 7203 |
돌아온깡통
|
11년 전 | 749 | |
| 7202 |
돌아온깡통
|
11년 전 | 726 | |
| 7201 |
돌아온깡통
|
11년 전 | 680 | |
| 7200 |
돌아온깡통
|
11년 전 | 710 | |
| 7199 |
돌아온깡통
|
11년 전 | 1332 | |
| 7198 |
돌아온깡통
|
11년 전 | 661 | |
| 7197 |
돌아온깡통
|
11년 전 | 978 | |
| 7196 |
돌아온깡통
|
11년 전 | 887 | |
| 7195 |
돌아온깡통
|
11년 전 | 623 | |
| 7194 |
돌아온깡통
|
11년 전 | 653 | |
| 7193 |
돌아온깡통
|
11년 전 | 718 | |
| 7192 |
돌아온깡통
|
11년 전 | 748 | |
| 7191 |
joe031
|
11년 전 | 1276 | |
| 7190 | 11년 전 | 4162 | ||
| 7189 | 11년 전 | 1255 | ||
| 7188 |
잘살아보자
|
11년 전 | 970 | |
| 7187 | 11년 전 | 1450 | ||
| 7186 |
kiplayer
|
11년 전 | 7557 | |
| 7185 | 11년 전 | 1145 | ||
| 7184 |
잘살아보자
|
11년 전 | 2344 | |
| 7183 |
잘살아보자
|
11년 전 | 1158 | |
| 7182 |
잘살아보자
|
11년 전 | 1227 | |
| 7181 | 11년 전 | 1497 | ||
| 7180 |
하얀비요일
|
11년 전 | 992 | |
| 7179 |
잘살아보자
|
11년 전 | 999 | |
| 7178 | 11년 전 | 988 | ||
| 7177 | 11년 전 | 1012 | ||
| 7176 | 11년 전 | 1667 | ||
| 7175 |
|
11년 전 | 1050 | |
| 7174 |
kiplayer
|
11년 전 | 1181 | |
| 7173 | 11년 전 | 962 | ||
| 7172 |
잘살아보자
|
11년 전 | 4649 | |
| 7171 |
잘살아보자
|
11년 전 | 716 | |
| 7170 | 11년 전 | 1080 | ||
| 7169 |
초심의설렘
|
11년 전 | 1479 | |
| 7168 | 11년 전 | 1013 | ||
| 7167 |
잘살아보자
|
11년 전 | 5292 | |
| 7166 |
잘살아보자
|
11년 전 | 3445 | |
| 7165 | 11년 전 | 4962 | ||
| 7164 | 11년 전 | 839 | ||
| 7163 | 11년 전 | 1214 | ||
| 7162 |
울라라라우
|
11년 전 | 1400 | |
| 7161 | 11년 전 | 1272 | ||
| 7160 |
skyler
|
11년 전 | 1194 | |
| 7159 |
|
11년 전 | 714 | |
| 7158 |
|
11년 전 | 3361 | |
| 7157 |
잘살아보자
|
11년 전 | 2898 | |
| 7156 |
잘살아보자
|
11년 전 | 2232 | |
| 7155 |
잘살아보자
|
11년 전 | 1462 | |
| 7154 |
잘살아보자
|
11년 전 | 1451 | |
| 7153 | 11년 전 | 2904 | ||
| 7152 |
울라라라우
|
11년 전 | 835 | |
| 7151 | 11년 전 | 1070 | ||
| 7150 |
잘살아보자
|
11년 전 | 2389 | |
| 7149 |
잘살아보자
|
11년 전 | 3301 | |
| 7148 |
잘살아보자
|
11년 전 | 1199 | |
| 7147 |
잘살아보자
|
11년 전 | 770 | |
| 7146 |
잘살아보자
|
11년 전 | 1411 | |
| 7145 |
잘살아보자
|
11년 전 | 725 | |
| 7144 |
잘살아보자
|
11년 전 | 1321 | |
| 7143 |
잘살아보자
|
11년 전 | 767 | |
| 7142 |
잘살아보자
|
11년 전 | 1460 | |
| 7141 |
잘살아보자
|
11년 전 | 1202 | |
| 7140 |
잘살아보자
|
11년 전 | 2022 | |
| 7139 |
잘살아보자
|
11년 전 | 3686 | |
| 7138 |
잘살아보자
|
11년 전 | 3182 | |
| 7137 |
잘살아보자
|
11년 전 | 3637 | |
| 7136 |
잘살아보자
|
11년 전 | 1393 | |
| 7135 |
gooroo
|
11년 전 | 1618 | |
| 7134 |
열라뽕똬이
|
11년 전 | 2325 | |
| 7133 |
|
11년 전 | 1025 | |
| 7132 | 11년 전 | 1437 | ||
| 7131 | 11년 전 | 3580 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기