Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Código de Listas Enlazadas
Código de Listas Enlazadas
#include<iostream.h>
#include<conio.h>
#include<PROCESS.H>
void InsNd (int Info[8],int Indice[8],int Inicio,int Disp, int Elemento, int Npos);
void InsNd (int Info[8],int Indice[8],int Inicio,int Disp, int Elemento, int Npos);
void main()
clrscr();
int op;
do{
clrscr();
cout<<"MENU PRINCIPAL"<<endl;
cout<<"1.-RECORRIDO NODO"<<endl;
cout<<"2.-BUSQUEDA NODO"<<endl;
cout<<"3.-INSERTAR NODO"<<endl;
cout<<"5. FINALIZAR"<<endl;
OMAR GALVEZ ÁLVAREZ LI
cin>>op;
clrscr();
switch (op){
case 1:
{" "},{"T"}};
int Indice[8]={5,7,6,1,-999,3,-999,4};
int Inicio=0,Disp=2;
Recorrido(Info,Indice,Inicio,Disp);
getch();
int Apuntador=Inicio;
OMAR GALVEZ ÁLVAREZ LI
while(Apuntador!=-999)
cout<<Info[Apuntador];
Apuntador=Indice[Apuntador];
break;
case 2:
int Info[8]={12,10,0,9,5,3,0,20};
int Indice[8]={5,7,6,1,-999,3,-999,4};
int Inicio=0,Disp=2,Elemento,Res;
cin>>Elemento;
Res=Busqueda(Info,Indice,Inicio,Disp,Elemento);
OMAR GALVEZ ÁLVAREZ LI
if(Res==-999)
cout<<"Dato No Encontrado...";
getch();
int Apuntador=Inicio;
while(Apuntador!=-999)
if(Elemento==Info[Apuntador])
return Apuntador;
OMAR GALVEZ ÁLVAREZ LI
Apuntador=Indice[Apuntador];
return Apuntador;
break;
case 3:
int Info[8]={12,10,0,9,5,3,0,20};
int Indice[8]={5,7,6,1,-999,3,-999,4};
int Inicio=0,Disp=2,Elemento,Res;
cout<<"Lista Original\n";
Recorrido(Info,Indice,Inicio,Disp);
cin>>Elemento;
OMAR GALVEZ ÁLVAREZ LI
Res=InsOrd(Info,Indice,Inicio,Elemento);
InsNd(Info,Indice,Inicio,Disp,Elemento,Res);
getch();
int Apuntador=Inicio;
while(Apuntador!=-999)
cout<<Info[Apuntador]<<endl;
Apuntador=Indice[Apuntador];
void InsNd(int Info[8],int Indice[8],int Inicio,int Disp, int Elemento, int Npos)
OMAR GALVEZ ÁLVAREZ LI
if(Disp!=-999)
int Apuntador=Disp;
Disp=Indice[Disp];
Info[Apuntador]=Elemento;
if(Npos==-999)
Indice[Apuntador]=Inicio;
Inicio=Apuntador;
else
{
OMAR GALVEZ ÁLVAREZ LI
Indice[Apuntador]=Indice[Npos];
Indice[Npos]=Apuntador;
Recorrido(Info,Indice,Inicio,Disp);
else
cout<<"Overflow...";
int Temp=-999,Temp2;
if(Inicio==Temp||Elemento<Info[Inicio])
return Temp;
Temp=Inicio;
OMAR GALVEZ ÁLVAREZ LI
Temp2=Indice[Inicio];
while(Temp2!=-999)
if(Elemento<Info[Temp2])
return Temp;
Temp=Temp2;
Temp2=Indice[Temp2];
return Temp;
break;
case 4:
int Info[8]={12,10,0,9,5,3,0,20};
int Indice[8]={5,7,6,1,-999,3,-999,4};
OMAR GALVEZ ÁLVAREZ LI
int Inicio=0,Disp=2,Elemento,Res;
cout<<"Lista Original\n";
Recorrido(Info,Indice,Inicio,Disp);
cin>>Elemento;
Res=InsOrd(Info,Indice,Inicio,Elemento);
InsNd(Info,Indice,Inicio,Disp,Elemento,Res);
getch();
int Apuntador=Inicio;
while(Apuntador!=-999)
OMAR GALVEZ ÁLVAREZ LI
cout<<Info[Apuntador]<<endl;
Apuntador=Indice[Apuntador];
void InsNd(int Info[8],int Indice[8],int Inicio,int Disp, int Elemento, int Npos)
if(Disp!=-999)
int Apuntador=Disp;
Disp=Indice[Disp];
Info[Apuntador]=Elemento;
if(Npos==-999)
{
OMAR GALVEZ ÁLVAREZ LI
Indice[Apuntador]=Inicio;
Inicio=Apuntador;
else
Indice[Apuntador]=Indice[Npos];
Indice[Npos]=Apuntador;
Recorrido(Info,Indice,Inicio,Disp);
else
cout<<"Overflow...";
}
OMAR GALVEZ ÁLVAREZ LI
int Temp=-999,Temp2;
if(Inicio==Temp||Elemento<Info[Inicio])
return Temp;
Temp=Inicio;
Temp2=Indice[Inicio];
while(Temp2!=-999)
if(Elemento<Info[Temp2])
return Temp;
Temp=Temp2;
Temp2=Indice[Temp2];
}
OMAR GALVEZ ÁLVAREZ LI
return Temp;
break;
case 5:
exit (0);
break;
default:
break;
getch();
cout<<" "<<endl;
cout<<" "<<endl;
}while(1==1);