Pascal/Turbo Pascal - ayuda con un procedimiento para invertir el orden de los elementos de un archivo

 
Vista:

ayuda con un procedimiento para invertir el orden de los elementos de un archivo

Publicado por Maxi (20 intervenciones) el 09/08/2013 04:37:36
Alguna ayuda con un procedimiento para invertir el orden de los elementos de un archivo y otro para ordenarlos?
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

ayuda con un procedimiento para invertir el orden de los elementos de un archivo

Publicado por ramon (2158 intervenciones) el 10/08/2013 12:49:16
Me puedes decir el tipo de archivo de registros de texto de que o pon mas información para
poder ayudarte mas puesto que sino mal.
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

ayuda con un procedimiento para invertir el orden de los elementos de un archivo

Publicado por Maxi (20 intervenciones) el 10/08/2013 17:38:18
Un archivo de caracteres, por ejemplo tenes a b c y que me lo invierta a c b a
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

ayuda con un procedimiento para invertir el orden de los elementos de un archivo

Publicado por ramon (2158 intervenciones) el 10/08/2013 19:07:20
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
{Mira te pongo carga sobre archivo y sobre array tu veras si te sirve}
 
 program caracter;
 uses
    crt;
  const
     maxcar = 6;
     nombre = 'c:\tp\bin\inversi.dat';
 
  type
     carateres = record
              elcar : char;
            end;
 
     ecaracter = array[1..maxcar] of char;
 
  var
    f : file of carateres;
    dt : carateres;
    ch : ecaracter;
    h, k : integer;
    arhi : boolean;
 
    procedure cargacaracteres(adond : char);
    var
       max, i : integer;
    begin
     if maxcar > 26 then
       max := 26
     else
       max := maxcar;
     if upcase(adond) = 'R' then
     begin
       for i := 1 to max do
       begin
          ch[i] := chr(96 + i);
       end;
     end;
     if upcase(adond) = 'A' then
     begin
         assign(f,nombre);
         rewrite(f);
         for i := 1 to max do
         begin
             dt.elcar := chr(96 + i);
             seek(f,i - 1);
             write(f,dt);
         end;
         close(f);
         arhi := true;
     end;
    end;
 
    procedure enorden_caracteres(adond : char);
    var
       max, g : integer;
    begin
       if maxcar > 26 then
       max := 26
     else
       max := maxcar;
       if upcase(adond) = 'R' then
       begin
       for g := 1 to max do
       write('  ',ch[g]);
       end;
       if upcase(adond) = 'A' then
       begin
          assign(f,nombre);
       {$I-} reset(f); {$I+}
       if ioresult <> 0 then
       begin
           writeln('Error De Archivo Pulse Una Tecla');
           readkey;
           exit;
       end
     else
        begin
           for g := 1 to max do
           begin
              seek(f,g - 1);
              read(f,dt);
              write('  ',dt.elcar);
           end;
           close(f);
        end;
       end;
    end;
 
    procedure invierte_caracteres(adond : char);
    var
       max, u : integer;
    begin
       if maxcar > 26 then
       max := 26
     else
       max := maxcar;
       if upcase(adond) = 'R' then
       begin
       for u := maxcar downto 1 do
       write('  ',ch[u]);
       end;
       if upcase(adond) = 'A' then
       begin
        assign(f,nombre);
       {$I-} reset(f); {$I+}
       if ioresult <> 0 then
       begin
           writeln('Error De Archivo Pulse Una Tecla');
           readkey;
           exit;
       end
     else
        begin
           for u := filesize(f) - 1 downto 0 do
           begin
               seek(f,u);
               read(f,dt);
               write('  ',dt.elcar);
           end;
           close(f);
          end;
       end;
    end;
 
   begin
       arhi := false;
       clrscr;
       writeln('****** Cargado Sobre Array ******');
       writeln;
       cargacaracteres('r');
       enorden_caracteres('r');
       writeln;
       invierte_caracteres('r');
       writeln;
       writeln;
       writeln('****** Cargado Sobre Archivo ******');
       writeln;
       cargacaracteres('a');
       enorden_caracteres('a');
       writeln;
       invierte_caracteres('a');
       writeln;
       readkey;
       if arhi = true then
       erase(f);
   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

ayuda con un procedimiento para invertir el orden de los elementos de un archivo

Publicado por ramon (2158 intervenciones) el 11/08/2013 15:28:14
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
{Archivo de texto}
 
 program texto;
 uses
    crt;
  const
     nombre = 'c:\tp\bin\prutext.txt';
 
 
  var
    caracter : char;
    f : text;
    cargo : boolean;
 
 
    procedure carga_archivo(nomb : string);
    var
      t : integer;
    begin
       assign(f,nomb);
    {$I-} reset(f); {$I+}
    if ioresult <> 0 then
    begin
        rewrite(f);
        write(f,caracter);
        close(f);
    end
  else
      begin
         Append(f);
         write(f,caracter);
         close(f);
      end;
      cargo := true;
    end;
 
   procedure entradas_caracter;
   var
      g : integer;
   begin
      for g := 1 to 6 do
      begin
         caracter := chr(96 + g);
         carga_archivo(nombre);
      end;
   end;
 
   procedure presenta_texto(nomb : string; como : char);
   var
      s : char;
      tx : string;
      i : integer;
    begin
    assign(f,nomb);
    {$I-} reset(f); {$I+}
    if ioresult <> 0 then
    begin
       writeln('Error De Archivo Pulse Una Tecla');
       readkey;
       exit;
    end
  else
     begin
         i := 1;
         while not eof(f) do
         begin
           read(f,s);
           tx[i] := s;
           tx[0] := chr(i);
           i := i + 1;
         end;
         close(f);
         if upcase(como) = 'N' then
         begin
            for i := 1 to length(tx) do
            write(tx[i]:3);
         end;
         if upcase(como) = 'I' then
         begin
            for i := length(tx) downto 1 do
            write(tx[i]:3);
         end;
       end;
    end;
 
 
  begin
      cargo := false;
      clrscr;
      entradas_caracter;
      writeln('***** Normal ******');
      writeln;
      presenta_texto(nombre,'n');
      writeln;
      writeln;
      writeln('***** Inverso *****');
      writeln;
      presenta_texto(nombre,'i');
      readkey;
      if cargo = true then
      erase(f);
  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