Pascal/Turbo Pascal - Liga Soccer

 
Vista:

Liga Soccer

Publicado por Ulises (12 intervenciones) el 19/05/2013 01:10:52
Hola, me gustaría saber cómo resolver un problema para realizar calendario de torneo para 20 jugadores en el que se enfrenten dos a dos sin repetir rival tipo round robin en pascal...Alguna idea?
Gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Liga Soccer

Publicado por ramon (2158 intervenciones) el 22/05/2013 14:23:35
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{Mira a qui tienes algo que puede mostrarte lo que pides}
 
program aaaaroun;
 uses
   crt;
 const
     max = 16;
 type
    equipos = array[1..max] of char;
 var
  n, i, j, tmp, ronda, m : integer;
  erro, x, y : integer;
  eq : equipos;
 
  function main(num : integer; equi : equipos) : integer;
  begin
     n := num;
     if num < 2 then
     val(equi[1],n,erro);
     if (n <= max) or (n < 2) then
     if (n and 1) = 1 then
     m := n + 1
   else
     m := n;
     x := 2;
     y := 2;
     gotoxy(x,y);write('Equipos -->');
     x := x + 13;
     for i := 1 to n do
     begin
        gotoxy(13 + (i * 3),y);write(i);
     end;
      x := 5;
      y := 3;
      for ronda := 1 to max - 1 do
      begin
          gotoxy(5,y);write('ronda = ',ronda);
          x := 16;
        for i := 1 to m do
        begin
          for j := 1 to m do
          begin
              if ((i + j) mod (m - 1)) = ronda mod (m - 1) then
              break;
           end;
              if (j = i) and (m <> n) then
              begin
                gotoxy(x,y);write('-');
              end
           else
              if (j = i) and (m = n) then
              begin
              gotoxy(x,y);write(n);
              x := 16 + (i * 3);
              tmp := i;
              end
            else
              begin
              gotoxy(x,y);write(j);
              x := 16 + (i * 3);
              end;
            end;
            if m = n then
            begin
            x := x - (1 * 3);
            gotoxy(x,y);write('  ');
            gotoxy(x,y);write(tmp);
            y := y + 1;
      end;
     end;
   end;
 
   begin
       clrscr;
       for i := 1 to max do
       begin
       eq[i] := chr(96 + i);
       gotoxy(13 + (i * 3),1);write(eq[i]);
       end;
       main(max,eq);
       readkey;
   end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Liga Soccer

Publicado por Ulises (6 intervenciones) el 22/05/2013 14:51:00
Gracias, ahora, ¿solo debo cambiar la variables max=16 por 20 ?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Liga Soccer

Publicado por elias (45 intervenciones) el 22/05/2013 15:15:25
Una pregunta hay alguna manera que pueda visualizar no solo la tabla generada sino por encuentro especifico? ejemplo: ronda 1: equipo 1 contra: tal o cual...y así con cada uno?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Liga Soccer

Publicado por ramon (2158 intervenciones) el 24/05/2013 14:09:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
{Mira esto ajustarlo a tu necesidad}
 
program aaaaroun;
 uses
   crt;
 const
     max = 16;
 type
    equipos = array[1..max] of char;
    losequipos = record
            q1 : integer;
            q2 : integer;
           end;
 
    juegan = array[1..max,1..2] of losequipos;
 
 var
  pq, n, i, j, tmp, ronda, m : integer;
  mn, ss, tt, erro, x, y : integer;
  eq : equipos;
  compt : array[1..max] of juegan;
  numer : array[1..(max * max)] of integer;
 
  function main(num : integer; equi : equipos) : integer;
  begin
     n := num;
     if num < 2 then
     val(equi[1],n,erro);
     if (n <= max) or (n < 2) then
     if (n and 1) = 1 then
     m := n + 1
   else
     m := n;
     x := 2;
     y := 2;
     gotoxy(x,y);write('Equipos -->');
     x := x + 13;
     for i := 1 to n do
     begin
        gotoxy(13 + (i * 3),y);write(i);
     end;
      x := 5;
      y := 3;
      for ronda := 1 to max - 1 do
      begin
          gotoxy(5,y);write('ronda = ',ronda);
          x := 16;
        for i := 1 to m do
        begin
          for j := 1 to m do
          begin
              if ((i + j) mod (m - 1)) = ronda mod (m - 1) then
              break;
           end;
              if (j = i) and (m <> n) then
              begin
                gotoxy(x,y);write('-');
              end
           else
              if (j = i) and (m = n) then
              begin
              numer[pq] := n;
              pq := pq + 1;
              gotoxy(x,y);write(n);
              x := 16 + (i * 3);
              tmp := i;
              end
            else
              begin
              numer[pq] := j;
              pq := pq + 1;
              gotoxy(x,y);write(j);
              x := 16 + (i * 3);
              end;
            end;
            if m = n then
            begin
            x := x - (1 * 3);
            gotoxy(x,y);write('  ');
            gotoxy(x,y);write(tmp);
            numer[pq - 1] := tmp;
            y := y + 1;
         end;
     end;
   end;
 
   procedure procesaequipos(grt : array of integer);
   var
      jor, hh, yt, xt : integer;
      sal : boolean;
   begin
       clrscr;
       yt := 1;
       xt := 1;
       sal := false;
       hh := 1;
       jor := 1;
     repeat
       writeln(' jornada ',jor,' : ',numer[yt],' contra ',numer[yt + 1]);
       compt[jor][xt,1].q1 := numer[yt];
       compt[jor][xt,2].q2 := numer[yt + 1];
       yt := yt + 2;
       xt := xt + 1;
       hh := hh + 1;
       if hh > (max div 2) then
       begin
       hh := 1;
       readln;
       clrscr;
       jor := jor + 1;
       end;
       if xt > (max * (max - 1) div 2) then
       sal := true;
     until sal = true;
   end;
 
   begin
       clrscr;
       for i := 1 to max do
       begin
       eq[i] := chr(96 + i);
       gotoxy(13 + (i * 3),1);write(eq[i]);
       end;
       pq := 1;
       main(max,eq);
       procesaequipos(numer);
       readkey;
   end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar