Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit unListDin;
- interface
- uses
- StdCtrls, sysUtils;
- type
- PNodo = ^Nodo;
- Nodo = record
- Nombre: String;
- NReg: Integer;
- Promedio: Real;
- CantMat: Integer;
- Prox: Pnodo;
- end;
- // Crear lista vacia (con nodo auxiliar)
- procedure Crear(var P: PNodo);
- // Insercion tipo pila. Lista desordenada
- procedure Agregar_Des(P: PNodo; ANombre: String; ANReg: Integer;
- APromedio: Real; ACantMat: Integer);
- // Insercion ordenada. Lista ordenada por numero de registro
- procedure Agregar_Ord(P: PNodo; ANombre: String; ANReg: Integer;
- APromedio: Real; ACantMat: Integer);
- // Eliminar nodo segun el numero de registro
- function Eliminar_Nreg(P: PNodo; ANReg: Integer): boolean;
- // Eliminar nodo segun la posicion
- function Eliminar_Pos(P: PNodo; Posicion: Integer): boolean;
- // Devuelve la cantidad de nodos
- function Cant_Nodos(P: PNodo): Integer;
- // Busca un dato (alumno por numero de registro) y devuelve su posicion.
- // Si no lo encuentra devuelve el valor 0.
- function Buscar(P: PNodo; ANReg: Integer): Integer;
- // Elimina la lista completa
- procedure Eliminar_Lista(P: PNodo; Posicion: Integer);
- // Muesta la lista de alumnos
- procedure MostrarLista(P: PNodo; var Memo: TMemo);
- implementation
- // Crear lista vacia (con nodo auxiliar)
- procedure Crear(var P: PNodo);
- begin
- New(P);
- P^.Prox:=nil;
- end;
- function crearNodo( ANombre: String; ANReg: Integer;
- APromedio: Real; ACantMat: Integer):PNodo;
- var
- x:PNodo;
- begin
- new(x);
- x^.Nombre := ANombre;
- x^.NReg := ANReg;
- x^.Promedio := APromedio;
- x^.CantMat := ACantMat;
- x^.Prox := nil;
- crearNodo := x;
- end;
- // Insercion tipo pila. Lista desordenada
- procedure Agregar_Des(P: PNodo; ANombre: String; ANReg: Integer;
- APromedio: Real; ACantMat: Integer);
- var
- x,y:PNodo;
- begin
- x := crearNodo(ANombre,ANReg,APromedio,ACantMat);
- y := p^.Prox;
- p^.prox := x;
- x^.prox := y;
- end;
- // Insercion ordenada. Lista ordenada por numero de registro
- procedure Agregar_Ord(P: PNodo; ANombre: String; ANReg: Integer;
- APromedio: Real; ACantMat: Integer);
- begin
- end;
- // Eliminar nodo segun el numero de registro
- function Eliminar_NReg(P: PNodo; ANReg: Integer): boolean;
- var
- x, y: PNodo;
- begin
- x:=P; y:=P^.Prox;
- while (y<>nil) do
- begin
- if (y^.NReg=ANReg) then Break;
- x:=y; y:=y^.Prox;
- end;
- if y<>nil then
- begin
- x^.Prox:=y^.Prox;
- Dispose(y);
- Eliminar_NReg:=true;
- end else
- Eliminar_NReg := false
- end;
- // Eliminar nodo segun la posicion
- function Eliminar_Pos(P: PNodo; Posicion: Integer): boolean;
- var
- i:integer;
- inPos:boolean;
- x,y:PNodo;
- begin
- i := 1;
- x := p;
- inPos := false;
- while(x^.Prox<>nil) and (not inPos) do
- begin
- if i = (Posicion) then
- inPos := true
- else
- begin
- x := x^.Prox;
- i := i + 1;
- end
- end;
- if inPos then
- begin
- y := x^.prox;
- x^.prox := y^.prox;
- dispose(y);
- end;
- Eliminar_Pos := inPos;
- end;
- // Devuelve la cantidad de nodos
- function Cant_Nodos(P: PNodo): Integer;
- begin
- end;
- // Busca un dato (alumno por numero de registro) y devuelve su posicion.
- // Si no lo encuentra devuelve el valor 0.
- function Buscar(P: PNodo; ANReg: Integer): Integer;
- begin
- end;
- // Elimina la lista completa
- procedure Eliminar_Lista(P: PNodo; Posicion: Integer);
- begin
- end;
- // Muesta la lista de alumnos
- procedure MostrarLista(P: PNodo; var Memo: TMemo);
- var
- cont: Integer;
- x: PNodo;
- Linea: String;
- begin
- x:=P^.Prox; cont:=1;
- Memo.Clear;
- while (x<>nil) do
- begin
- Linea:=Format('%.3d) %s. Numero de registro: %d. Materias: %d. Promedio: %g',
- [Cont, x^.Nombre, x^.NReg, x^.CantMat, x^.Promedio]);
- Memo.Lines.Add(Linea);
- x:=x^.Prox; Inc(Cont);
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement