Pascal/Turbo Pascal - Escribir programa que tenga como salida otro archivo donde el renglón esté escrito en orden inverso

 
Vista:

Escribir programa que tenga como salida otro archivo donde el renglón esté escrito en orden inverso

Publicado por juan ignacio (1 intervención) el 23/05/2016 02:46:44
Buenas Gente, vengo buscando ayuda para un TP en pascal, cualquier idea o comentario sobre este me viene bien. Paso a mostrar el ejercicio:Dado un archivo de texto, de un renglón. Escribir un programa que tenga como salida otro archivo
donde el renglón esté escrito en orden inverso:
Por ejemplo:
Entrada
Los días de octubre son hermosos
Salida
sosomreh nos erbutco ed saíd soL

DESDE YA; 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

Escribir programa que tenga como salida otro archivo donde el renglón esté escrito en orden inverso

Publicado por ramon (2158 intervenciones) el 23/05/2016 17:54:37
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
{Mira esto}
 
 program lineatext;
  uses
    crt;
  const
     tex = 'Los días de octubre son hermosos';
     archi = 'mitex.txt';
     archi2 = 'mitex2.txt';
 
  var
    f : text;
    dat : string;
 
  procedure creaarchivo;
  begin
      assign(f,archi);
      rewrite(f);
      dat := copy(tex,1,length(tex));
      writeln(f,tex);
      close(f);
  end;
 
 
  procedure creainvertido;
  var
    i, h : longint;
    camb : string;
  begin
     assign(f,archi);
   {$I-} reset(f); {$I+}
     if ioresult <> 0 then
     begin
       writeln('   Error De Archivo O No Existe Pulse Una Tecla');
       readkey;
     end
  else
     begin
        h := 1;
        readln(f,dat);
        close(f);
        assign(f,archi2);
        rewrite(f);
        for i := length(dat) downto 1 do
        begin
           camb[h] := dat[i];
           camb[0] := chr(h);
           h := h + 1;
        end;
          writeln(f,camb);
          close(f);
     end;
   end;
 
 
     procedure leeinvertido;
     begin
        assign(f,archi2);
   {$I-} reset(f); {$I+}
     if ioresult <> 0 then
     begin
       writeln('   Error De Archivo O No Existe Pulse Una Tecla');
       readkey;
     end
  else
     begin
        readln(f,dat);
        close(f);
        writeln('   ',dat);
     end;
   end;
 
   procedure leenormal;
   begin
      assign(f,archi);
   {$I-} reset(f); {$I+}
     if ioresult <> 0 then
     begin
       writeln('   Error De Archivo O No Existe Pulse Una Tecla');
       readkey;
     end
  else
     begin
        readln(f,dat);
        close(f);
        writeln('   ',dat);
     end;
   end;
 
 
   begin
      clrscr;
      creaarchivo;
      creainvertido;
      writeln;
      leenormal;
      writeln;
      leeinvertido;
      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