Pascal/Turbo Pascal - Ejercicio de archivos

 
Vista:
sin imagen de perfil

Ejercicio de archivos

Publicado por Leo (1 intervención) el 02/09/2014 19:37:13
¿Alguien me puede ayudar con este ejercicio?


WP_20140829_001


Hice el primero, el que sirve para introduccir los datos. ¿Me podrían ayudar con el que dice que hay que ingresar por teclado una matriz?

¡Gracias!

Saludos.
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

Ejercicio de archivos

Publicado por ramon (39 intervenciones) el 03/09/2014 17:43:32
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
{A ver si esto te ayuda}
 
program vendedores;
 uses
    crt;
  type
     archivendedores = record
              numero : integer;
            apellnom : string[25];
                cuil : string[25];
             end;
 
     tabventas = array[1..50] of record
                 numero : integer;
              cantvendi : integer;
                  end;
 
     archiventas = record
             numero : integer;
           apellnom : string[25];
           cantvent : integer;
           end;
 
   var
     arvf : file of archivendedores;
     avtf : file of archiventas;
    tabla : tabventas;
     cont : integer;
     dat1 : archivendedores;
     dat2 : archiventas;
     tec : char;
 
   procedure guardavendedores(v : archivendedores);
   begin
      assign(arvf,'vendedor.dat');
   {$I-} reset(arvf); {$I+}
     if ioresult <> 0 then
     begin
        rewrite(arvf);
        seek(arvf,0);
        write(arvf,v);
        close(arvf);
     end
  else
      begin
         seek(arvf,filesize(arvf));
         write(arvf,v);
         close(arvf);
      end;
   end;
 
   procedure guardaventas(vn : archiventas);
   begin
      assign(avtf,'ventas.dat');
   {$I-} reset(avtf); {$I+}
     if ioresult <> 0 then
     begin
        rewrite(avtf);
        seek(avtf,0);
        write(avtf,vn);
        close(avtf);
     end
  else
      begin
         seek(avtf,filesize(avtf));
         write(avtf,vn);
         close(avtf);
      end;
   end;
 
  procedure tomadatos;
  begin
     clrscr;
     writeln('   ***** Entrada Datos Vendedor *****');
     writeln;
     write('             Numero : ');
     readln(dat1.numero);
     write('  Apellido Y Nombre : ');
     readln(dat1.apellnom);
     write('               Cuil : ');
     readln(dat1.cuil);
     dat2.numero := dat1.numero;
     dat2.apellnom := dat1.apellnom;
     guardavendedores(dat1);
     write('             Ventas : ');
     readln(dat2.cantvent);
     guardaventas(dat2);
  end;
 
  procedure cargaventas(var vt : tabventas);
  var
     s, i : integer;
     carg : longint;
  begin
        assign(avtf,'ventas.dat');
      {$I-} reset(avtf); {$I+}
        if ioresult <> 0 then
         begin
            exit;
         end
      else
        begin
        carg := filesize(avtf) - 1;
        if carg > 49 then
        carg := 49;
        for i := 0 to carg do
         begin
            seek(avtf,i);
            read(avtf,dat2);
            vt[i + 1].numero := dat2.numero;
            vt[i + 1].cantvendi := dat2.cantvent;
          end;
          close(avtf);
          cont := integer(carg + 1);
      end;
  end;
 
  procedure preseatatabla;
  var
     h : integer;
  begin
     for h := 1 to cont do
     writeln('   ',tabla[h].numero,'            ',tabla[h].cantvendi);
     writeln;
     writeln('   Pulse Una Tecla');
     readkey;
  end;
 
 
 
  begin
     clrscr;
   repeat
       tomadatos;
       writeln;
       writeln('  Desewa Entrar Mas Datos [S/N]');
       repeat
       tec := upcase(readkey);
       until tec in['S','N'];
   until tec = 'N';
     cargaventas(tabla);
     preseatatabla;
  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