Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program pacial_TAD
- Uses TAD Insumo;
- type
- lista = ^nodo
- nodo = record
- nombre:string;
- direccion:string;
- li:Listai;
- sig:lista;
- end;
- listai= ^nodo
- nodo = record
- i:insu;
- sig:listai;
- end;
- listaE = ^nodo
- nodo = record
- nombre:string;
- direccion:string;
- a:arbol;
- sig:listae;
- end;
- arbol = ^nodo
- nodo = record
- precio:real;
- li:listai;
- hd:nil;
- hi:nil;
- end;
- var l:lista; li:listaI; le:listaE; a:arbol; i,i2:insu; precio:real; direccion:string;
- procedure crearArbol ( var a:arbol )
- begin
- a:= nil;
- end;
- procedure incisoA (l:lista; var le:listae; precio:real; direccion:string )
- var act:string;
- begin
- while ( l <> nil ) do begin
- act:= l^.nombre;
- direccion:= l^.direccion;
- while ( act = l^.nombre ) do
- while ( l^.li <> nil ) do begin
- precio:= verPrecio (l^.li.i);
- instertarListaE ( nombre, direccion, precio, l^.li, le);
- l^.li:= l^.li^.sig;
- end;
- l:= l^.sig;
- end;
- procedure instertarListaE ( nombre, direccion: string; precio:real; i:insu; var le:listaE )
- var act, ant, nue:listaE;
- begin
- new (nue);
- nue^.nombre:= nombre;
- nue^.direccion:= direccion;
- insertarArbol ( le^.a, precio, i );
- ant:= le;
- act:= le;
- while ( act <> nil ) and ( nombre > act^.nombre ) do begin
- ant:= act;
- act:= act^.sig;
- end;
- if ( ant = act ) then begin
- nue^.sig:= le;
- le:= nue;
- else begin
- ant^.sig:= nue;
- nue^.sig:= act;
- end;
- end;
- procedure insertarArbol ( var a:arbol; precio:real; i:insu )
- begin
- if ( a = nil ) then begin
- a^.precio:= precio;
- insertarListaI( a^.li, i);
- a^.hi:= nil;
- a^.hd:= nil;
- else if ( precio = a^.precio ) then
- insertarListaI ( a^.li, i );
- else if ( precio > a^.precio ) then
- insertarArbol ( a^.hd, precio, i );
- else insertarArbol ( a^.hi, precio, i );
- end;
- procedure insertarListaI ( var li:listaI; i:insu )
- var nue:listaI;
- begin
- new ( nue );
- asignar ( nue^.i; i)
- nue^.sig:= li;
- li:= nue;
- end;
- procedure incisoB ( le: listaE )
- var total,max:integer; maxN, act: string;
- begin
- max:= -1;
- while ( le <> nil ) do begin
- total:= 0;
- act:= le^.nombre;
- while ( act = le^.nombre ) do begin
- totalEnArbol ( le^.a, total),
- le:= le^.sig;
- if ( act <> le^.nombre ) then
- calcularMax(max, maxN, act, total);
- end;
- write ('La empresa que provee mas insumos es: ', maxN, 'con la cantidad de ', total, ' insumos.');
- end;
- procedure totalEnArbol ( a:arbol, var total:integer)
- begin
- if ( a <> nil ) then
- totalEnArbol(a^.hi, total);
- totalEnArbol(a^.hd, total);
- totalEnListaArbol( a^.li, total);
- end;
- procedure totalEnListaArbol ( li:listaI, var total:integer )
- begin
- while ( li <> nil ) do begin
- total:= total + 1;
- li:= li^.sig;
- end;
- end;
- procedure incisoC ( var le:listaE)
- begin
- while ( le <> nil ) do begin
- modificar ( le^.a);
- le:= le^.sig;
- end;
- end;
- procedure modificar ( var a: arbol )
- begin
- if ( a <> nil ) then
- modificarLi(a^.hi);
- modificar (a^.hd);
- modificar (a^.hi);
- end;
- end;
- procedure modificarLi ( var li:listaI )
- var nN:string;
- begin
- nN:='Papel A4';
- while ( li <> nil ) do
- if ( verCategoria (li^.i) = 10 ) then
- modNombre (li^.i, nN);
- end;
- procedure incisoD ( le:listaE )
- var act:string;
- begin
- while ( le <> nil ) do begin
- act:= le^.nombre;
- while ( act = le^.nombre ) do begin
- informarArbol ( le^.a ),
- le:= le^.sig;
- end;
- end;
- end;
- procedure informarArbol ( a:arbol )
- begin
- if ( a <> nil ) then
- if ( a^.precio > 25 ) then
- informarArbol(a^.hd);
- informarArbol(a^.hi);
- informarListaI(a^.li);
- else if ( a^.precio < 25 ) then
- informarArbol(a^.hd);
- end;
- procedure informarListaI ( li: listaI )
- begin
- while ( li <> nil ) do begin
- informar (l^.i);
- li:= li^.sig;
- end;
- end;
- procedure informar ( i:insu )
- var nom, descripcion: string; precio:real; categoria:integer;
- begin
- verNombre (i,nom);
- verDescripcion(i,descripcion);
- precio:= verPrecio(i);
- categoria:= verCategoria(i);
- writeln('Nombre: ', nom);
- writeln('Descripcion: ', descripcion);
- writeln('Categoria: ', categoria);
- writeln('Precio: ', precio);
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement