Guest User

Untitled

a guest
Aug 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 4.89 KB | None | 0 0
  1. (* Construir un programa en memoria "dinamica" que contenga
  2.  
  3.  Construir un programa que permita ingresar la siguiente informacion
  4.  a una lista bi-direccional
  5.   -nombre: string
  6.   -edad: 16
  7.   -partido politico: string
  8.   -club de sus amores: string
  9.   -casado/soltero/viudo/divorciado/complicado/mandoneado
  10.    con la soga al cuello: integer
  11.  
  12.    Debe permitir la entrega de informacion por medio del nombre o por su estado civil
  13.  
  14. *)
  15.  
  16. uses crt;
  17. Type Lista = ^Nodo;
  18.      Nodo = Record
  19.      nombre:String;
  20.      edad:Integer;
  21.      pp:String;
  22.      club:String;
  23.      estciv:integer;
  24.      Sig,ant:Lista;
  25.      end;
  26. var p, q, r: Lista;
  27.     listacreada: boolean;
  28.  
  29. (* Variables de menu *)
  30. var s:char;
  31.     a:integer;
  32.  
  33. procedure llenado;
  34.  var c:char;
  35.  begin clrscr;
  36.   c:='0';
  37.   new(q^.sig);
  38.   q^.ant:=nil;   (* No hay anterior *)
  39.   While c<>'@' Do
  40.      begin
  41.      Write('    Nombre Persona: '); Readln(q^.nombre);
  42.      Write('              Edad: '); Readln(q^.edad);
  43.      Write('  Partido Politico: '); Readln(q^.pp);
  44.      Write('    Club Preferido: '); Readln(q^.club);
  45.      Write('Estado Sentimental: '); Readln(q^.estciv);
  46.  
  47.  
  48.  
  49.      Write('Desea continuar ingresando datos? Presione @ para terminar: ');
  50.      c := ReadKey;
  51.      if c<>'@' then
  52.      begin
  53.        new(q^.sig);
  54.  
  55.        q^.sig^.ant:=q;
  56.        q:=q^.sig;
  57.        WriteLn;
  58.      end;
  59.    end;
  60.    q^.sig:=nil; (* No hay siguiente *)
  61.    listacreada:=true;
  62.  
  63.  end;
  64.  
  65.  
  66. procedure insertar;
  67.  var c:char;
  68.  begin clrscr;
  69.   While(q^.sig<>nil) do
  70.    q:=q^.sig; (* avanzar hasta el final para no borrar nada *)
  71.  
  72.   new(q^.sig);
  73.   q:=q^.sig;
  74.   While c<>'@' Do
  75.    begin
  76.      Write('    Nombre Persona: '); Readln(q^.nombre);
  77.      Write('              Edad: '); Readln(q^.edad);
  78.      Write('  Partido Politico: '); Readln(q^.pp);
  79.      Write('    Club Preferido: '); Readln(q^.club);
  80.      Write('Estado Sentimental: '); Readln(q^.estciv);
  81.  
  82.      Write('Desea continuar ingresando datos? Presione @ para terminar: ');
  83.      c := ReadKey;
  84.      if c<>'@' then
  85.      begin
  86.        new(q^.sig);
  87.        q^.sig^.ant:=q;
  88.        q:=q^.sig;
  89.        WriteLn;
  90.      end;  (* End if *)
  91.  
  92.    end; (* End While *)
  93.    q^.sig:=nil; (* No hay siguiente *)
  94.  
  95.  
  96.  
  97. end; (* End Procedure *)
  98.  
  99.  
  100. procedure mostrarlista;
  101. var i,mostrarmensaje:integer;
  102.  begin clrscr;
  103.    WriteLn('Presione una tecla para mostrar siguiente producto...');
  104.    textcolor(10); writeln('+---------------------------------------------------------+');
  105.  
  106.  
  107.    While q<>nil do
  108.    begin
  109.     if (listacreada = false) then
  110.      begin
  111.       textcolor(15);WriteLn('Recuerde llenar la lista primero... (Presione una tecla para volver al menu)');
  112.       ReadKey;
  113.       exit;
  114.      end;
  115.     textcolor(10);write('|');textcolor(15);WriteLn('    Nombre Persona: ', q^.nombre);
  116.     textcolor(10);write('|');textcolor(15);WriteLn('              Edad: ', q^.edad);
  117.     textcolor(10);write('|');textcolor(15);WriteLn('  Partido Politico: ', q^.pp);
  118.     textcolor(10);write('|');textcolor(15);WriteLn('    Club Preferido: ', q^.club);
  119.     textcolor(10);write('|');textcolor(15);WriteLn('Estado Sentimental: ', q^.estciv);
  120.     q:=q^.sig;
  121.  
  122.     textcolor(10); writeln('+---------------------------------------------------------+');
  123.     ReadKey;
  124.    end;
  125.    
  126.    q:=q^.ant;
  127.    (*While q<>nil do
  128.    begin *)
  129.     textcolor(10);write('|');textcolor(15);WriteLn('    Nombre Persona: ', q^.nombre);
  130.     textcolor(10);write('|');textcolor(15);WriteLn('              Edad: ', q^.edad);
  131.     textcolor(10);write('|');textcolor(15);WriteLn('  Partido Politico: ', q^.pp);
  132.     textcolor(10);write('|');textcolor(15);WriteLn('    Club Preferido: ', q^.club);
  133.     textcolor(10);write('|');textcolor(15);WriteLn('Estado Sentimental: ', q^.estciv);
  134.     q:=q^.ant;
  135.  
  136.     textcolor(10); writeln('+---------------------------------------------------------+');
  137.     ReadKey;
  138.    (*end;    *)
  139.     WriteLn('Se ha Llegado al principio');
  140.     ReadKey;
  141.  end;
  142. procedure salir;
  143.  begin clrscr;
  144.   WriteLn('Gracias por utilizar este programa..');
  145.   Delay(500);
  146.   s:='0';
  147.  
  148.  end;
  149.  
  150. procedure buscarpersona;
  151.  begin
  152.  
  153.  end;
  154.  
  155.  
  156.  
  157. begin  { principal }
  158.        new(p);
  159.        s:='1';
  160.        listacreada:=false;
  161.        while (s = '1') do
  162.        begin
  163.          clrscr;
  164.          gotoxy(10,2); textcolor(11); writeln('Registro de Personas v1.1'); textcolor(10);
  165.          gotoxy(10,4); writeln('1. LLenado de Lista');
  166.          gotoxy(10,5); writeln('2. Insertar Item');
  167.          gotoxy(10,6); writeln('3. Mostrar Lista');
  168.          gotoxy(10,7); writeln('4. Buscar Persona de lista');
  169.          gotoxy(10,8); writeln('5. Salir');
  170.          gotoxy(10,10); textcolor(2); write('Que desea hacer? (Pulse numero): ');
  171.          textcolor(10); q:=p; ReadLn(a);
  172.          case a of
  173.           1: llenado;
  174.           2: insertar;
  175.           3: mostrarlista;
  176.           4: buscarpersona;
  177.           5: salir;
  178.          end;
  179.          textcolor(15);
  180.        end;
  181.  
  182. end.
Add Comment
Please, Sign In to add comment