Pascal/Turbo Pascal - !!! Ayuda programa pascal!!!

 
Vista:

!!! Ayuda programa pascal!!!

Publicado por joshua (2 intervenciones) el 17/05/2013 18:27:08
Necesito ayuda urgente en pascal
necesito hacer un programa que tenga los siguientes datos de libros
Autor, Nombre del libro, dia,mes,año en que fue solicitado el libro. estos datos son fijos (total 5 registros)

luego se deben mostrar y comparar la fecha de solicitud con la fecha actual y decir cuantos dias hay de mora en la entrega del libro

estructura base

Type

puntero= ^libros;
libros = record
autor: string [20]
nombre : string [30]
dia : integer;
mes : integer;
ano : integer;
sig:puntero;
end;



porfavor ayuda
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 programa pascal!!!

Publicado por ramon (2158 intervenciones) el 23/05/2013 15:17:40
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
{A ver si esto te sirve}
 
program bibleoteca;
 uses
    crt;
 
  type
     string20 = string[20];
     string30 = string[30];
 
     puntero = ^libros;
     libros = record
          autor : string20;
         nombre : string30;
            dia : integer;
            mes : integer;
            ayo : integer;
            sig : puntero;
         end;
 
   var
     actual, primero, anterior : puntero;
     f : file of libros;
     tecla : char;
     carga : libros;
 
  procedure iniciapuntero;
  begin
     primero := nil;
  end;
 
  procedure crea_archivo(cualtomo : libros);
   begin
       assign(f,'bibliote.dat');
    {$I-} reset(f); {$I+}
    if ioresult <> 0 then
    begin
        rewrite(f);
        seek(f,0);
        write(f, cualtomo);
        close(f);
    end
  else
     begin
       seek(f,filesize(f));
       write(f, cualtomo);
       close(f);
     end;
   end;
 
  procedure entra_datos;
  begin
      clrscr;
      writeln('   **** Entrada De Datos ****');
      writeln;
      write('    Autor  : ');
      readln(actual^.autor);
      write('    Nombre : ');
      readln(actual^.nombre);
      write('    Dia    : ');
      readln(actual^.dia);
      write('    Mes    : ');
      readln(actual^.mes);
      write('    A¤o    : ');
      readln(actual^.ayo);
  end;
 
  procedure inserta_datos;
  begin
      if primero = nil then
      begin
         new(actual);
         entra_datos;
         primero := actual;
         actual^.sig := nil;
       end
   else
      begin
         anterior := actual;
         new(actual);
         entra_datos;
         anterior^.sig := actual;
         actual^.sig := nil;
      end;
      crea_archivo(actual^);
  end;
 
  procedure compara_fechas(nomb : string30; d, m, a : integer);
  var
    vuscar : puntero;
    td, tm, ta, t : integer;
    encontre : boolean;
  begin
      encontre := false;
      if primero = nil then
      begin
      writeln('  Primero Carge Los Datos');
      writeln('  Pulse Una [Tecla]');
      readkey;
      end
    else
      begin
      vuscar := primero;
      for t := 1 to length(nomb) do
      nomb[t] := upcase(nomb[t]);
      while vuscar <> nil do
      begin
         for t := 1 to length(vuscar^.nombre) do
         vuscar^.nombre[t] := upcase(vuscar^.nombre[t]);
         if vuscar^.nombre = nomb then
         begin
           td := d - vuscar^.dia;
           tm := m - vuscar^.mes;
           ta := a - vuscar^.ayo;
           clrscr;
           writeln('  Los Resultados Son ');
           writeln;
           writeln('  Tomado Fecha   : ',vuscar^.dia,'/',vuscar^.mes,'/',
                                                    vuscar^.ayo);
           writeln('  Debuelto Fecha : ',d,'/',m,'/',a);
           if (tm = 0) and (ta = 0) then
           writeln('  Dias De Demora : ',td);
           if (tm > 0) and (ta = 0) then
           writeln('  Dias De Demora : ',(30 - vuscar^.dia) + td);
           writeln;
           writeln('   Pulse Una [Tecla] ');
           readkey;
           encontre := true;
           break;
         end;
          vuscar := vuscar^.sig;
      end;
      if encontre = false then
      begin
         clrscr;
         writeln('    Error Dato No Encontrado Pulse Una [Tecla]');
         readkey;
      end;
     end;
  end;
 
  procedure cargadatos;
  var
    i : longint;
  begin
      assign(f,'bibliote.dat');
    {$I-} reset(f); {$I+}
    if ioresult <> 0 then
    begin
       clrscr;
       writeln('   Error Archivo No Encontrado Pulse Una [Tecla]');
       readkey;
       exit;
    end
  else
    begin
      iniciapuntero;
      i := 0;
    repeat
      seek(f,i);
      read(f,carga);
      if primero = nil then
      begin
         new(actual);
         actual^ := carga;
         primero := actual;
         actual^.sig := nil;
       end
   else
      begin
         anterior := actual;
         new(actual);
         actual^ := carga;
         anterior^.sig := actual;
         actual^.sig := nil;
      end;
      i := i + 1;
    until (i > filesize(f) - 1) or (memavail < sizeof(libros));
    close(f);
    end;
  end;
 
  procedure visualizar_datos;
  var
    p : longint;
    datos : libros;
    tec : char;
  begin
     assign(f,'bibliote.dat');
    {$I-} reset(f); {$I+}
    if ioresult <> 0 then
    begin
       clrscr;
       writeln('   Error Archivo No Encontrado Pulse Una [Tecla]');
       readkey;
       exit;
    end
  else
    begin
        p := 0;
      repeat
          seek(f,p);
          read(f,datos);
          clrscr;
          writeln('  Autor        : ',datos.autor);
          writeln('  Nombre       : ',datos.nombre);
          writeln('  Dia          : ',datos.dia);
          writeln('  Mes          : ',datos.mes);
          writeln('  A¤o          : ',datos.ayo);
          writeln;
          writeln(' Para Segir Pulse Espacio Salir[Esc]');
          tec := readkey;
          if tec <> #27 then
          p := p + 1;
      until (p > filesize(f) - 1) or (tec = #27);
      close(f);
    end;
  end;
 
 
  procedure menu;
  var
    sal : boolean;
    nom : string30;
    d, m, y : integer;
  begin
     sal := false;
    repeat
      clrscr;
      writeln('  **** Menu Generel ****');
      writeln;
      writeln('  1 : Entrada De Datos');
      writeln('  2 : Comparar Fecha');
      writeln('  3 : Cargar Datos Del Archivo');
      writeln('  4 : Visualizar Datos Archivo');
      writeln('  5 : Salir');
      writeln;
      writeln('  >>>> Elija Opcion <<<<');
      repeat
          tecla := readkey;
      until tecla in['1','2','3','4','5'];
      clrscr;
   case tecla of
  '1' : inserta_datos;
  '2' : begin
           write('  Nombre : ');
           readln(nom);
           write('  Dia    : ');
           readln(d);
           write('  Mes    : ');
           readln(m);
           write('  A¤o    : ');
           readln(y);
           compara_fechas(nom, d, m, y);
        end;
  '3' : cargadatos;
  '4' : visualizar_datos;
  '5' : sal := true;
    end;
    until sal = true;
    if primero <> nil then
    dispose(actual);
  end;
 
  begin
      iniciapuntero;
      menu;
  end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
2
Comentar

!!! Ayuda programa pascal!!!

Publicado por joshua (2 intervenciones) el 23/05/2013 19:03:24
Muchas gracias me sirvió bastante.....
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