Pascal/Turbo Pascal - De C a Pascal, se puede?

 
Vista:

De C a Pascal, se puede?

Publicado por gonzalo (2 intervenciones) el 07/05/2013 14:30:44
Hola, tengo un programa en C, como llevarlo a pascal...alguien sabe?

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
#include <stdio.h>
#include <stdlib.h>
 
void uso(void);
 
int main(int argc, char *argv[])
{
	unsigned int n,i,j,tmp, ronda, N;
 
	if (argc<2) { uso(); return 1; }
	n=atoi(argv[1]);
	if (n>=17 || n<2) { uso(); return 1; }
	if (n & 1) N=n+1;
	else       N=n;
 
	printf(" Equipo -->");
	for (i=1; i<=n; i++) printf(" %2d ",i);
	printf("\n");
	for (ronda=1; ronda<N; ronda++) {
		printf(" Ronda %2d: ",ronda);
		for (i=1; i<N; i++) {
			for (j=1; j<N; j++) {
				if ( (i+j)%(N-1)== ronda%(N-1)) break;
			}
			if (j==i && N!=n) 	 printf("  - ");
			else if (j==i && N==n)	{printf(" %2d ",n); tmp=i;}
			else printf(" %2d ",j);
		}
		if (N==n) printf(" %2d ",tmp);
		printf("\n");
	}
	return 0;
}
 
void uso(void)
{
 
	printf("Uso: rndrobin <n>\n");
	printf("Calcula las rondas para un torneo con n (1<n<17) equipos.\n");
	return ;
}
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

De C a Pascal, se puede?

Publicado por ramon (2158 intervenciones) el 16/05/2013 16:29:57
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
{A qui tienes}
 
 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
1
Comentar

De C a Pascal, se puede?

Publicado por Gonzalo (12 intervenciones) el 20/05/2013 20:46:10
Gracias, 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

De C a Pascal, se puede?

Publicado por ramon (2158 intervenciones) el 23/05/2013 15:19:31
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 te Ayudara}
 
 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