NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Program listas;

Type
Lista= ^Nodo;
Nodo= Record
Dato: integer;
Sig: Lista;
End;
arrlistas= array [1..4] of Lista;


{AGREGARALFINAL
Agrega al final de la lista l}
{Procedure agregarAlFinal ( var l,ult: Lista; num:integer);
begin
//creo el nodo
//si es el primer nodo actualizo l
//si no es el primero engancho con el ultimo
//actualizo el puntero al ultimo
end;}



{INSERTAR
Inserta un n?mero en la lista en orden creciente}
Procedure Insertar ( var pri: lista; num: integer);
var
ant, nue, act: lista;
begin
{Crea un nuevo nodo con el numero num}
new (nue);
nue^.dato := num;
act := pri;
ant := pri;
{Recorro mientras no se termine la lista y no encuentro la posici?n}
while (act <> NIL) and (act^.dato < num) do begin
ant := act;
act := act^.sig ;
end;
if (ant = act) then
pri := nue {el dato va al principio}
else
ant^.sig := nue; {el dato va entre otros dos o al final}
nue^.sig := act ;
end;



{CREARLISTA
Crea una lista l con numeros random con longitudLista elementos}
Procedure crearListaOrdenada(var l:lista; longitudLista: integer);
var
i,n: integer;
begin
l := nil;
for i := 1 to longitudLista do begin
n := random (100);
Insertar(l, n);
end;
end;


{IMPRIMIR
Imprime la lista L}
Procedure Imprimir (l:lista);
Begin
while (l <> NIL) do begin
write ('[', l^.dato, '] ');
l:= l^.sig;
end;
writeln;
end;
procedure asignacion (l1,l2,l3,l4:lista;var vl:arrlistas);
begin
vl[1]:=l1;
vl[2]:=l2;
vl[3]:=l3;
vl[4]:=l4;
end;

procedure agregarmin(var l5:lista;var ult:lista;min:integer);
var aux:lista;
begin
new(aux);
aux^.dato:=min;
aux^.sig:=nil;
if (l5=nil) then
l5:=aux
else begin
aux^.sig:=ult;
ult^.sig:=aux;
end;
ult:=aux
end;
procedure buscarmin(vl:arrlistas; var min:integer);
var i,imin:integer;
begin
min:=999999;
for i:=1 to 4 do begin
if (vl[i]<>nil) then
if (vl[i]^.dato<min) then
min:= vl[i]^.dato;
imin:= i;
end;
if (min<>999999) then vl[imin]:=vl[imin]^.sig;
end;

procedure merge (vl:arrlistas; var l5:lista);
var
ult:lista; min:integer
begin
min:= 0;
while (min <> 999999) do begin
buscarmin(vl,min);
if (min <> 999999) then
agregarmin (l5, ult, min);
end;
end;
Var
L1, L2, L3, L4, L5: Lista;
vl:arrlistas;

begin
randomize;

{Creo las listas}
crearListaOrdenada(L1, 4);
crearListaOrdenada(L2, 3);
crearListaOrdenada(L3, 5);
crearListaOrdenada(L4, 7);
writeln('Listas generadas: ');
writeln;
write('L1 --> ');
imprimir(L1);
write('L2 --> ');
imprimir(L2);
write('L3 --> ');
imprimir(L3);
write('L4 --> ');
imprimir(L4);
asignacion(l1,l2,l3,l4,vl);
merge(vl,l5);
write('L5 --> ');
imprimir(L5);
readln;





end.
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.