소스 정리하다가 옛날에 축구관련 사이트 작업한게 있었는데 있길래 한번 올려봅니다.
작업당시에 기존 존재하는 소스가 있나 싶어서 찾아봤는데 없는거 같길래 만들었어요~
자주 쓰이는 경기방식중에는
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에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 2630 |
|
15년 전 | 818 | |
| 2629 | 15년 전 | 893 | ||
| 2628 | 15년 전 | 1087 | ||
| 2627 | 15년 전 | 1788 | ||
| 2626 |
angpang
|
15년 전 | 1102 | |
| 2625 |
|
15년 전 | 1194 | |
| 2624 | 15년 전 | 969 | ||
| 2623 | 15년 전 | 917 | ||
| 2622 | 15년 전 | 1288 | ||
| 2621 | 15년 전 | 1740 | ||
| 2620 | 15년 전 | 1018 | ||
| 2619 | 15년 전 | 1358 | ||
| 2618 |
terrorboys
|
15년 전 | 1625 | |
| 2617 |
mummy
|
15년 전 | 982 | |
| 2616 | 15년 전 | 906 | ||
| 2615 |
windday
|
15년 전 | 1062 | |
| 2614 | 15년 전 | 1119 | ||
| 2613 | 15년 전 | 934 | ||
| 2612 | 15년 전 | 1213 | ||
| 2611 | 15년 전 | 1289 | ||
| 2610 | 15년 전 | 1222 | ||
| 2609 | 15년 전 | 3137 | ||
| 2608 |
DiZiNOr
|
15년 전 | 820 | |
| 2607 | 15년 전 | 1366 | ||
| 2606 |
|
15년 전 | 942 | |
| 2605 | 15년 전 | 1761 | ||
| 2604 | 15년 전 | 722 | ||
| 2603 | 15년 전 | 881 | ||
| 2602 |
bitmaster
|
15년 전 | 899 | |
| 2601 | 15년 전 | 902 | ||
| 2600 | 15년 전 | 1639 | ||
| 2599 | 15년 전 | 2938 | ||
| 2598 | 15년 전 | 2024 | ||
| 2597 | 15년 전 | 1932 | ||
| 2596 | 15년 전 | 916 | ||
| 2595 | 15년 전 | 1022 | ||
| 2594 | 15년 전 | 966 | ||
| 2593 |
순천홈페이지
|
15년 전 | 859 | |
| 2592 | 15년 전 | 1145 | ||
| 2591 | 15년 전 | 843 | ||
| 2590 | 15년 전 | 1321 | ||
| 2589 |
dannykim
|
15년 전 | 745 | |
| 2588 |
dannykim
|
15년 전 | 650 | |
| 2587 | 15년 전 | 1531 | ||
| 2586 | 15년 전 | 794 | ||
| 2585 | 15년 전 | 1239 | ||
| 2584 | 15년 전 | 1103 | ||
| 2583 | 15년 전 | 786 | ||
| 2582 | 15년 전 | 806 | ||
| 2581 | 15년 전 | 713 | ||
| 2580 |
|
15년 전 | 693 | |
| 2579 | 15년 전 | 859 | ||
| 2578 | 15년 전 | 1116 | ||
| 2577 | 15년 전 | 2273 | ||
| 2576 |
확실한방법
|
15년 전 | 881 | |
| 2575 | 15년 전 | 971 | ||
| 2574 | 15년 전 | 997 | ||
| 2573 | 15년 전 | 993 | ||
| 2572 | 15년 전 | 1066 | ||
| 2571 |
|
15년 전 | 685 | |
| 2570 | 15년 전 | 1942 | ||
| 2569 |
|
15년 전 | 781 | |
| 2568 | 15년 전 | 1588 | ||
| 2567 | 15년 전 | 743 | ||
| 2566 |
dannykim
|
15년 전 | 755 | |
| 2565 | 15년 전 | 1421 | ||
| 2564 |
기획매니아
|
15년 전 | 1050 | |
| 2563 | 15년 전 | 1324 | ||
| 2562 | 15년 전 | 1623 | ||
| 2561 | 15년 전 | 1261 | ||
| 2560 | 15년 전 | 1348 | ||
| 2559 | 15년 전 | 718 | ||
| 2558 |
|
15년 전 | 2271 | |
| 2557 | 15년 전 | 1013 | ||
| 2556 | 15년 전 | 747 | ||
| 2555 | 15년 전 | 1091 | ||
| 2554 | 15년 전 | 797 | ||
| 2553 | 15년 전 | 2042 | ||
| 2552 | 15년 전 | 1079 | ||
| 2551 | 15년 전 | 908 | ||
| 2550 |
|
15년 전 | 994 | |
| 2549 | 15년 전 | 951 | ||
| 2548 |
|
15년 전 | 964 | |
| 2547 |
|
15년 전 | 1051 | |
| 2546 | 15년 전 | 545 | ||
| 2545 | 15년 전 | 474 | ||
| 2544 | 15년 전 | 441 | ||
| 2543 | 15년 전 | 1143 | ||
| 2542 |
|
15년 전 | 959 | |
| 2541 | 15년 전 | 806 | ||
| 2540 | 15년 전 | 799 | ||
| 2539 | 15년 전 | 1196 | ||
| 2538 | 15년 전 | 3198 | ||
| 2537 | 15년 전 | 1067 | ||
| 2536 |
|
15년 전 | 1868 | |
| 2535 | 15년 전 | 1144 | ||
| 2534 |
|
15년 전 | 963 | |
| 2533 | 15년 전 | 2603 | ||
| 2532 | 15년 전 | 1610 | ||
| 2531 |
|
15년 전 | 2505 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기