소스 정리하다가 옛날에 축구관련 사이트 작업한게 있었는데 있길래 한번 올려봅니다.
작업당시에 기존 존재하는 소스가 있나 싶어서 찾아봤는데 없는거 같길래 만들었어요~
자주 쓰이는 경기방식중에는
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에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7930 | 9년 전 | 453 | ||
| 7929 | 9년 전 | 388 | ||
| 7928 | 9년 전 | 465 | ||
| 7927 | 9년 전 | 379 | ||
| 7926 | 9년 전 | 688 | ||
| 7925 | 9년 전 | 404 | ||
| 7924 | 9년 전 | 386 | ||
| 7923 | 9년 전 | 380 | ||
| 7922 | 9년 전 | 414 | ||
| 7921 | 9년 전 | 433 | ||
| 7920 | 9년 전 | 343 | ||
| 7919 | 9년 전 | 352 | ||
| 7918 | 9년 전 | 507 | ||
| 7917 | 9년 전 | 358 | ||
| 7916 | 9년 전 | 446 | ||
| 7915 | 9년 전 | 454 | ||
| 7914 | 9년 전 | 467 | ||
| 7913 | 9년 전 | 633 | ||
| 7912 | 9년 전 | 466 | ||
| 7911 | 9년 전 | 398 | ||
| 7910 | 9년 전 | 445 | ||
| 7909 | 9년 전 | 551 | ||
| 7908 | 9년 전 | 488 | ||
| 7907 | 9년 전 | 429 | ||
| 7906 | 9년 전 | 444 | ||
| 7905 | 9년 전 | 410 | ||
| 7904 | 9년 전 | 403 | ||
| 7903 | 9년 전 | 400 | ||
| 7902 | 9년 전 | 589 | ||
| 7901 |
|
9년 전 | 767 | |
| 7900 | 9년 전 | 648 | ||
| 7899 | 9년 전 | 431 | ||
| 7898 | 9년 전 | 428 | ||
| 7897 | 9년 전 | 388 | ||
| 7896 | 9년 전 | 400 | ||
| 7895 | 9년 전 | 518 | ||
| 7894 | 9년 전 | 432 | ||
| 7893 | 9년 전 | 405 | ||
| 7892 | 9년 전 | 444 | ||
| 7891 | 9년 전 | 807 | ||
| 7890 | 9년 전 | 1231 | ||
| 7889 | 9년 전 | 766 | ||
| 7888 |
limsy1987
|
9년 전 | 578 | |
| 7887 | 9년 전 | 607 | ||
| 7886 | 9년 전 | 496 | ||
| 7885 | 9년 전 | 467 | ||
| 7884 | 9년 전 | 458 | ||
| 7883 | 9년 전 | 461 | ||
| 7882 | 9년 전 | 522 | ||
| 7881 | 9년 전 | 495 | ||
| 7880 | 9년 전 | 618 | ||
| 7879 | 9년 전 | 503 | ||
| 7878 | 9년 전 | 1276 | ||
| 7877 | 9년 전 | 809 | ||
| 7876 | 9년 전 | 544 | ||
| 7875 | 9년 전 | 614 | ||
| 7874 |
|
9년 전 | 830 | |
| 7873 | 9년 전 | 550 | ||
| 7872 | 9년 전 | 715 | ||
| 7871 | 9년 전 | 530 | ||
| 7870 | 9년 전 | 648 | ||
| 7869 | 9년 전 | 467 | ||
| 7868 | 9년 전 | 504 | ||
| 7867 | 9년 전 | 501 | ||
| 7866 | 9년 전 | 559 | ||
| 7865 | 9년 전 | 499 | ||
| 7864 | 9년 전 | 562 | ||
| 7863 | 9년 전 | 553 | ||
| 7862 | 9년 전 | 517 | ||
| 7861 | 9년 전 | 688 | ||
| 7860 | 9년 전 | 666 | ||
| 7859 | 9년 전 | 443 | ||
| 7858 | 9년 전 | 746 | ||
| 7857 | 9년 전 | 1136 | ||
| 7856 | 9년 전 | 566 | ||
| 7855 | 9년 전 | 800 | ||
| 7854 | 9년 전 | 753 | ||
| 7853 | 9년 전 | 646 | ||
| 7852 | 9년 전 | 565 | ||
| 7851 | 9년 전 | 557 | ||
| 7850 | 9년 전 | 634 | ||
| 7849 | 9년 전 | 400 | ||
| 7848 | 9년 전 | 468 | ||
| 7847 | 9년 전 | 711 | ||
| 7846 | 9년 전 | 498 | ||
| 7845 | 9년 전 | 467 | ||
| 7844 | 9년 전 | 438 | ||
| 7843 | 9년 전 | 475 | ||
| 7842 | 9년 전 | 459 | ||
| 7841 | 9년 전 | 429 | ||
| 7840 | 9년 전 | 442 | ||
| 7839 | 9년 전 | 485 | ||
| 7838 | 10년 전 | 552 | ||
| 7837 | 10년 전 | 384 | ||
| 7836 | 10년 전 | 442 | ||
| 7835 | 10년 전 | 517 | ||
| 7834 |
|
10년 전 | 1227 | |
| 7833 | 10년 전 | 487 | ||
| 7832 | 10년 전 | 462 | ||
| 7831 | 10년 전 | 623 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기