소스 정리하다가 옛날에 축구관련 사이트 작업한게 있었는데 있길래 한번 올려봅니다.
작업당시에 기존 존재하는 소스가 있나 싶어서 찾아봤는데 없는거 같길래 만들었어요~
자주 쓰이는 경기방식중에는
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에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7430 |
|
11년 전 | 4947 | |
| 7429 | 11년 전 | 1780 | ||
| 7428 |
멋진남자임
|
11년 전 | 1172 | |
| 7427 |
sdflksdj2
|
11년 전 | 830 | |
| 7426 | 11년 전 | 1366 | ||
| 7425 | 11년 전 | 1392 | ||
| 7424 | 11년 전 | 1054 | ||
| 7423 |
SeungYeon
|
11년 전 | 565 | |
| 7422 | 11년 전 | 811 | ||
| 7421 |
sdflksdj2
|
11년 전 | 691 | |
| 7420 | 11년 전 | 973 | ||
| 7419 |
|
11년 전 | 1405 | |
| 7418 |
멋진남자임
|
11년 전 | 1440 | |
| 7417 | 11년 전 | 608 | ||
| 7416 |
senseme
|
11년 전 | 1233 | |
| 7415 | 11년 전 | 963 | ||
| 7414 | 11년 전 | 715 | ||
| 7413 | 11년 전 | 4850 | ||
| 7412 | 11년 전 | 4407 | ||
| 7411 |
holla
|
11년 전 | 898 | |
| 7410 | 11년 전 | 4254 | ||
| 7409 | 11년 전 | 3929 | ||
| 7408 | 11년 전 | 4273 | ||
| 7407 | 11년 전 | 5090 | ||
| 7406 | 11년 전 | 4737 | ||
| 7405 | 11년 전 | 4303 | ||
| 7404 | 11년 전 | 765 | ||
| 7403 | 11년 전 | 5683 | ||
| 7402 | 11년 전 | 1520 | ||
| 7401 |
|
11년 전 | 979 | |
| 7400 | 11년 전 | 2975 | ||
| 7399 |
멋진남자임
|
11년 전 | 920 | |
| 7398 |
파랑새1597
|
11년 전 | 2708 | |
| 7397 | 11년 전 | 2277 | ||
| 7396 |
basketball
|
11년 전 | 1375 | |
| 7395 | 11년 전 | 1615 | ||
| 7394 | 11년 전 | 934 | ||
| 7393 | 11년 전 | 2075 | ||
| 7392 | 11년 전 | 852 | ||
| 7391 |
잘살아보자
|
11년 전 | 5365 | |
| 7390 |
잘살아보자
|
11년 전 | 2229 | |
| 7389 |
잘살아보자
|
11년 전 | 3323 | |
| 7388 |
파랑새1597
|
11년 전 | 932 | |
| 7387 | 11년 전 | 1108 | ||
| 7386 |
프리랜서퍼블리셔
|
11년 전 | 973 | |
| 7385 | 11년 전 | 1572 | ||
| 7384 |
울라라라우
|
11년 전 | 892 | |
| 7383 | 11년 전 | 1559 | ||
| 7382 |
잘살아보자
|
11년 전 | 4230 | |
| 7381 |
잘살아보자
|
11년 전 | 2000 | |
| 7380 |
잘살아보자
|
11년 전 | 1944 | |
| 7379 |
잘살아보자
|
11년 전 | 5910 | |
| 7378 |
senseme
|
11년 전 | 1902 | |
| 7377 |
잘살아보자
|
11년 전 | 2751 | |
| 7376 | 11년 전 | 2419 | ||
| 7375 |
잘살아보자
|
11년 전 | 1053 | |
| 7374 |
잘살아보자
|
11년 전 | 3166 | |
| 7373 |
잘살아보자
|
11년 전 | 2483 | |
| 7372 |
잘살아보자
|
11년 전 | 5834 | |
| 7371 |
잘살아보자
|
11년 전 | 3470 | |
| 7370 |
잘살아보자
|
11년 전 | 1917 | |
| 7369 |
잘살아보자
|
11년 전 | 2175 | |
| 7368 |
ksdhtm56
|
11년 전 | 575 | |
| 7367 | 11년 전 | 1438 | ||
| 7366 | 11년 전 | 936 | ||
| 7365 | 11년 전 | 3547 | ||
| 7364 |
잘살아보자
|
11년 전 | 1399 | |
| 7363 |
잘살아보자
|
11년 전 | 1372 | |
| 7362 |
잘살아보자
|
11년 전 | 1512 | |
| 7361 | 11년 전 | 3597 | ||
| 7360 | 11년 전 | 3563 | ||
| 7359 | 11년 전 | 3382 | ||
| 7358 |
멋진남자임
|
11년 전 | 1030 | |
| 7357 | 11년 전 | 3417 | ||
| 7356 | 11년 전 | 2604 | ||
| 7355 | 11년 전 | 3198 | ||
| 7354 |
파랑새1597
|
11년 전 | 652 | |
| 7353 |
잘살아보자
|
11년 전 | 2430 | |
| 7352 |
잘살아보자
|
11년 전 | 2421 | |
| 7351 |
잘살아보자
|
11년 전 | 2483 | |
| 7350 |
잘살아보자
|
11년 전 | 1478 | |
| 7349 |
잘살아보자
|
11년 전 | 1971 | |
| 7348 |
잘살아보자
|
11년 전 | 1287 | |
| 7347 |
잘살아보자
|
11년 전 | 1084 | |
| 7346 |
멋진남자임
|
11년 전 | 1651 | |
| 7345 | 11년 전 | 995 | ||
| 7344 | 11년 전 | 3878 | ||
| 7343 | 11년 전 | 3660 | ||
| 7342 | 11년 전 | 1288 | ||
| 7341 | 11년 전 | 2526 | ||
| 7340 |
|
11년 전 | 941 | |
| 7339 | 11년 전 | 1740 | ||
| 7338 | 11년 전 | 3351 | ||
| 7337 | 11년 전 | 3666 | ||
| 7336 | 11년 전 | 4605 | ||
| 7335 | 11년 전 | 979 | ||
| 7334 | 11년 전 | 1538 | ||
| 7333 | 11년 전 | 2940 | ||
| 7332 |
|
11년 전 | 1112 | |
| 7331 |
KeePin뽁이
|
11년 전 | 1106 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기