Pascal/Turbo Pascal - Ayuda Con Pascal Pilas y Colas

 
Vista:

Ayuda Con Pascal Pilas y Colas

Publicado por Jose Gomez (4 intervenciones) el 26/11/2013 20:57:09
Buenas.. Necesito Ayuda Urgente! Con un programa en pascal... Mi profesora no nos explico nada de lo que es pilas y colas y nos mando Un trabajo Practico o como quieran llamarlo... para mañana.. Obviamente nose de pilas y colas y lo Hice en lista.. Y Alguien Me puede ayudar cn este programa.. Pasarlo de Lista a Pilas y colas..
El programa dice asi:

Hice El programa en Lista y corre todo perfectamente! mas nose nada de pilas y colas ayuda!

Un banco tiene guardados los registros de los movimientos en una lista. Los movimientos
están ordenados primero por fecha y luego por numero de cuenta.
(crear pila)
El tipo del elemento de la lista es:
TElemLista
Fecha (Clave ordenamiento 1) (TDA FECHA)
Nro_Cta (Clave ordenamiento 2)
Monto
Tipo (Deposito/Extracción)
Realizar procedimientos para este TDA que:
•Permita Calcular la cantidad de depósitos realizados entre un rango fecha
por ejemplo el 01/01/2013 y el
31/07/2013.

Permita Calcular el total depositado y extraído de cada cuenta en el año 2013.
•Permita Calcular el saldo de la cuenta 8894 del año 2013.
· Debe resolver el problema implementando pilas y colas

Program PilasYColas;

uses crt;


type Pila = ^nodo;
nodo = record
dia, mes, ano : longint;
ced:string;
nom:string ;
ape : string ;
mon, tipo: integer;
cuent: integer ;
depo : integer;
sig :Pila;
end;
var
primer,aux,anterior: Pila;


Seleccion: integer;

procedure registro_datosglobal;
procedure registro_datos;
begin
repeat

writeln(' Fecha : ');
write('Introduzca Dia : ');
readln(aux^.dia);
write('Introduzca Mes : ');
readln(aux^.mes);
writeln('Introduzca Ano : ');
readln(aux^.ano);

if (aux^.dia > 31) {or (aux^.mes >12) or (aux^.ano <2013> 31)then
begin
writeln ('FECHA INVALIDA');
writeln ('---------------------------------------------------');
writeln('Pulse enter para continuar');
readln;
end
else
begin
if (aux^.mes >12)then begin

writeln ('FECHA INVALIDA');
writeln ('---------------------------------------------------');
writeln('Pulse enter para continuar');
readln;
end;
end;
if (aux^.ano <=2012 ) then begin
writeln ('FECHA INVALIDA');
writeln('Pulse enter para continuar');
readln;
end;


until ( (aux^.dia <= 31) and (aux^.mes <12>= 2013)) ;

clrscr;
writeln('Introduzca el nombre');
readln (aux^.nom);
writeln('Introduzca la cedula');
readln (aux^.ced );
Writeln ('--------------------------------------------');
Writeln (' Desea crear una cuenta: ');
Writeln ('1: Ahorro 2: Corriente');
readln (aux^.tipo);
if (aux^.tipo = 1) then
begin

writeln ('Su cuenta de Ahorro esta creada');
end;

If (aux^.tipo = 2) then
begin

writeln ('Su cuenta Corriente esta creada');
end;


Writeln ('--------------------------------------------');
Writeln ('Introduzca el numero de la cuenta');
readln (aux^.cuent);
writeln ('inserte monto inicial');
readln (aux^.mon);
end;
begin
if primer = nil then
begin
new(aux);
registro_datos;
primer := aux;
aux^.sig := nil;
end
else
begin
anterior := aux;
new(aux);
registro_datos;
anterior^.sig := aux;
aux^.sig := nil;
end;

end;




procedure deposito ();
var
depos:Pila;
mondepo,nucuenta: integer;

begin
depos:=primer;
while (depos <> nil ) do begin

writeln('Introduzca El numero de Cuenta ');
readln(nucuenta);
clrscr;
if (depos^.cuent = nucuenta ) then begin

writeln ('Introduzca el Monto que desea depositar');
readln (mondepo);
depos^.mon:= (( depos^.mon)+ (mondepo));

writeln ('Su saldo es: ');
write (aux^.mon);
end;
depos:=depos^.sig;
end;
end;

procedure retiro ();
var
res:Pila;
monre,ncuenta: integer;


begin
res:=primer;
writeln('Indique el Numero de Cuenta');
readln(ncuenta);
clrscr;
if (primer = nil) then begin
writeln('ERROR no Hay Ningun Numero de Cuenta Registrado');
writeln('Pulse enter para continuar');
readln;

end;

while (res <> nil ) do begin

if (res^.cuent = ncuenta )then begin
writeln ('Introduzca el Monto que desea retirar');
readln (monre);
res^.mon:= (( res^.mon)- (monre));

writeln ('Su saldo es: '); write (aux^.mon);;

end;
res:=res^.sig;
end;

end;


procedure mostrar ();
var
mostra:Pila;
begin
clrscr;
mostra:=primer;

if (primer = nil) then begin
writeln('ERROR no Hay Ningun Numero de Cuenta o Usuario Registrado ');
writeln('Pulse enter para continuar');
readln;

end;
while mostra <> nil do
begin
writeln('ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ');
Writeln('Fecha de Apertura');
Write (' '); Write(mostra^.dia);
Write(' / '); Write(mostra^.mes);
Write(' / '); Write (mostra^.ano);
Writeln();
writeln('.............................................');
Writeln ('Numero de Cuenta:'); Writeln (mostra^.cuent);
writeln;
writeln ('Su cuenta es: ');
if (mostra^.tipo = 1) then
begin
writeln ('ahorro');
end;
if (mostra^.tipo = 2) then
begin
writeln ('corriente');
end;
writeln('.............................................');
Write('Nombre :'); Write(mostra^.nom); Writeln();
Write('cedula:');write(mostra^.ced);Writeln();
writeln ('saldo total: '); writeln (mostra^.mon);
writeln('ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ');
readkey;
mostra:=mostra^.sig;

end;



end;



BEGIN
Seleccion:=0;
repeat
begin
clrscr;
Writeln ('');
Writeln ('');
Writeln ('***** BIENVENIDOS ***** ');
Writeln ('');
Writeln ('1. Crear Cuenta');
Writeln ('2. Deposito');
Writeln ('3. Retiro ');
Writeln ('4. Mostrar ');
writeln ('. SALIR DEL SISTEMA');
Writeln ('');
writeln('Seleccione la Opcion: ');
readln(Seleccion);
clrscr;
Case Seleccion of
1:
begin
registro_datosglobal;


end;
2 :
begin
deposito ();


end;
3:
begin

retiro ();
end;
4:
begin
mostrar ();

end;

5: Writeln ('Fin.....');
Else (writeln (' Opcion incorrecta'));

end;
end;


until (Seleccion = 5);

END.
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 Pascal Pilas y Colas

Publicado por ramon (2158 intervenciones) el 27/11/2013 13:57:06
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
{A qui tienes la formas de pilas y colas espero te sirva}
 
 uses
     crt;
 
  {Esto seria la pila}
  type
    lapila = ^elnodopila;
    elnodopila = record
          dia, mes, ano : longint;
          ced : string;
          nom : string ;
          ape : string ;
          mon, tipo : integer;
          cuent : integer ;
           depo : integer;
          sig : lapila
       end;
 
   var
     pil : elnodopila;
 
   procedure iniciapila(var pila: lapila);
   begin
      pila := nil
   end;
 
   function pilavacia(pila : lapila): boolean;
   begin
      pilavacia := pila = nil
   end;
 
  procedure entada_datos(var eldato :  elnodopila);
  begin
      writeln('***** Entrada Datos *****');
      writeln;
      write('  Entre Dia      : ');
      readln(eldato.dia);
      write('  Entre Mes      : ');
      readln(eldato.mes);
      write('  Entre A¤o      : ');
      readln(eldato.ano);
      write('  Entre Cedula   : ');
      readln(eldato.ced);
      write('  Entre Nombre   : ');
      readln(eldato.nom);
      write('  Entre Apellido : ');
      readln(eldato.ape);
      write('  Entre Monton   : ');
      readln(eldato.mon);
      write('  Entre Tipo     : ');
      readln(eldato.tipo);
      write('  Entre Cuente   : ');
      readln(eldato.cuent);
      write('  Entre Deposito : ');
      readln(eldato.depo);
  end;
 
  procedure anadirapila(datos : elnodopila; var pila: lapila);
  var
    auxil : lapila;
    begin
       auxil := pila;
       New(pila);
       pila^ := datos;
       pila^.sig := auxil
    end;
 
  procedure anulaPila(var pila : lapila);
  var
    auxil : lapila;
    begin
      auxil := pila;
      pila := pila^.sig;
      dispose(auxil)
   end;
 
{Esto seria la cola}
 
type
     nodocola = ^lacola;
     lacola = record
          dia, mes, ano : longint;
          ced : string;
          nom : string ;
          ape : string ;
          mon, tipo : integer;
          cuent : integer ;
           depo : integer;
           sige : nodocola;
       end;
 
      puntcola = record
          primero: nodocola;
             fin : nodocola;
        end;
 
     procedure iniciocola(var cola: puntcola);
     begin
        cola.primero := nil;
        cola.fin := nil;
    end;
 
    procedure entradaacola(dato: lacola; var cola : puntcola);
    var
      auxi : nodocola;
      begin
          New(auxi);
          auxi^ := dato;
          auxi^.sige := nil;
          if cola.fin <> nil then
          begin
             cola.fin^.sige := auxi;
             cola.fin := auxi;
          end
       else
            begin
               cola.primero := auxi;
               cola.fin := auxi;
            end;
         end;
 
       procedure anulardecola(var cola : puntcola);
       var
         auxi : nodocola;
         begin
         if cola.primero = cola.fin then
         begin
            auxi := cola.primero;
            dispose(auxi);
            cola.primero := nil;
            cola.fin := nil;
          end
       else
          begin
             auxi := cola.primero;
             cola.primero := auxi^.sige;
             dispose(auxi)
          end;
        end;
 
     procedure MostrarCola(cola: puntcola);
     var
       auxi : nodocola;
       begin
          if cola.fin = nil then
          WriteLn('Cola Vacia')
       else
          begin
             auxi := cola.primero;
      repeat
         WriteLn('  Fecha    = ',auxi^.dia,'/',auxi^.mes,'/',auxi^.ano);
         writeln('  Cedula   = ',auxi^.ced);
         writeln('  Nombre   = ',auxi^.nom);
         writeln('  Apellido = ',auxi^.ape);
         writeln('  Monton   = ',auxi^.mon);
         writeln('  Tipo     = ',auxi^.tipo);
         writeln('  Cuenta   = ',auxi^.cuent);
         writeln('  Deposito = ',auxi^.depo);
         writeln;
         writeln('*** Pulse Una Tecla ***');
         readkey;
         clrscr;
         auxi := auxi^.sige;
     until auxi = nil;
     writeln;
     writeln('<<<< Final De Datos >>>>');
     readkey;
    end;
  end;
 
 begin
 
 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 Pascal Pilas y Colas

Publicado por Jose Gomez (4 intervenciones) el 28/11/2013 07:30:41
GRACIAS HERMANO ME SALVASTES! Ya Hice el resto que tenia q hacer! Gracias
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