Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* Construir un programa en memoria "dinamica" que contenga
- Construir un programa que permita ingresar la siguiente informacion
- a una lista bi-direccional
- -nombre: string
- -edad: 16
- -partido politico: string
- -club de sus amores: string
- -casado/soltero/viudo/divorciado/complicado/mandoneado
- con la soga al cuello: integer
- Debe permitir la entrega de informacion por medio del nombre o por su estado civil
- *)
- uses crt;
- Type Lista = ^Nodo;
- Nodo = Record
- nombre:String;
- edad:Integer;
- pp:String;
- club:String;
- estciv:integer;
- Sig,ant:Lista;
- end;
- var p, q, r: Lista;
- listacreada: boolean;
- (* Variables de menu *)
- var s:char;
- a:integer;
- procedure llenado;
- var c:char;
- begin clrscr;
- c:='0';
- new(q^.sig);
- q^.ant:=nil; (* No hay anterior *)
- While c<>'@' Do
- begin
- Write(' Nombre Persona: '); Readln(q^.nombre);
- Write(' Edad: '); Readln(q^.edad);
- Write(' Partido Politico: '); Readln(q^.pp);
- Write(' Club Preferido: '); Readln(q^.club);
- Write('Estado Sentimental: '); Readln(q^.estciv);
- Write('Desea continuar ingresando datos? Presione @ para terminar: ');
- c := ReadKey;
- if c<>'@' then
- begin
- new(q^.sig);
- q^.sig^.ant:=q;
- q:=q^.sig;
- WriteLn;
- end;
- end;
- q^.sig:=nil; (* No hay siguiente *)
- listacreada:=true;
- end;
- procedure insertar;
- var c:char;
- begin clrscr;
- While(q^.sig<>nil) do
- q:=q^.sig; (* avanzar hasta el final para no borrar nada *)
- new(q^.sig);
- q:=q^.sig;
- While c<>'@' Do
- begin
- Write(' Nombre Persona: '); Readln(q^.nombre);
- Write(' Edad: '); Readln(q^.edad);
- Write(' Partido Politico: '); Readln(q^.pp);
- Write(' Club Preferido: '); Readln(q^.club);
- Write('Estado Sentimental: '); Readln(q^.estciv);
- Write('Desea continuar ingresando datos? Presione @ para terminar: ');
- c := ReadKey;
- if c<>'@' then
- begin
- new(q^.sig);
- q^.sig^.ant:=q;
- q:=q^.sig;
- WriteLn;
- end; (* End if *)
- end; (* End While *)
- q^.sig:=nil; (* No hay siguiente *)
- end; (* End Procedure *)
- procedure mostrarlista;
- var i,mostrarmensaje:integer;
- begin clrscr;
- WriteLn('Presione una tecla para mostrar siguiente producto...');
- textcolor(10); writeln('+---------------------------------------------------------+');
- While q<>nil do
- begin
- if (listacreada = false) then
- begin
- textcolor(15);WriteLn('Recuerde llenar la lista primero... (Presione una tecla para volver al menu)');
- ReadKey;
- exit;
- end;
- textcolor(10);write('|');textcolor(15);WriteLn(' Nombre Persona: ', q^.nombre);
- textcolor(10);write('|');textcolor(15);WriteLn(' Edad: ', q^.edad);
- textcolor(10);write('|');textcolor(15);WriteLn(' Partido Politico: ', q^.pp);
- textcolor(10);write('|');textcolor(15);WriteLn(' Club Preferido: ', q^.club);
- textcolor(10);write('|');textcolor(15);WriteLn('Estado Sentimental: ', q^.estciv);
- q:=q^.sig;
- textcolor(10); writeln('+---------------------------------------------------------+');
- ReadKey;
- end;
- q:=q^.ant;
- (*While q<>nil do
- begin *)
- textcolor(10);write('|');textcolor(15);WriteLn(' Nombre Persona: ', q^.nombre);
- textcolor(10);write('|');textcolor(15);WriteLn(' Edad: ', q^.edad);
- textcolor(10);write('|');textcolor(15);WriteLn(' Partido Politico: ', q^.pp);
- textcolor(10);write('|');textcolor(15);WriteLn(' Club Preferido: ', q^.club);
- textcolor(10);write('|');textcolor(15);WriteLn('Estado Sentimental: ', q^.estciv);
- q:=q^.ant;
- textcolor(10); writeln('+---------------------------------------------------------+');
- ReadKey;
- (*end; *)
- WriteLn('Se ha Llegado al principio');
- ReadKey;
- end;
- procedure salir;
- begin clrscr;
- WriteLn('Gracias por utilizar este programa..');
- Delay(500);
- s:='0';
- end;
- procedure buscarpersona;
- begin
- end;
- begin { principal }
- new(p);
- s:='1';
- listacreada:=false;
- while (s = '1') do
- begin
- clrscr;
- gotoxy(10,2); textcolor(11); writeln('Registro de Personas v1.1'); textcolor(10);
- gotoxy(10,4); writeln('1. LLenado de Lista');
- gotoxy(10,5); writeln('2. Insertar Item');
- gotoxy(10,6); writeln('3. Mostrar Lista');
- gotoxy(10,7); writeln('4. Buscar Persona de lista');
- gotoxy(10,8); writeln('5. Salir');
- gotoxy(10,10); textcolor(2); write('Que desea hacer? (Pulse numero): ');
- textcolor(10); q:=p; ReadLn(a);
- case a of
- 1: llenado;
- 2: insertar;
- 3: mostrarlista;
- 4: buscarpersona;
- 5: salir;
- end;
- textcolor(15);
- end;
- end.
Add Comment
Please, Sign In to add comment