Está en la página 1de 14

OMAR GALVEZ ÁLVAREZ LI

CÓDIGO DE LISTAS ENLAZADAS

#include<iostream.h>

#include<conio.h>

#include<PROCESS.H>

void Recorrido(char Info[8][2],int Indice[8],int Inicio,int Disp);

int Busqueda (int Info[8],int Indice[8],int Inicio,int Disp,int Elemento);

int InsOrd (int Info[8],int Indice[8],int Inicio,int Elemento);

void Recorrido(int Info[8],int Indice[8],int Inicio,int Disp);

void InsNd (int Info[8],int Indice[8],int Inicio,int Disp, int Elemento, int Npos);

int InsOrd (int Info[8],int Indice[8],int Inicio,int Elemento);

void Recorrido(int Info[8],int Indice[8],int Inicio,int Disp);

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<<"4. ELIMINAR NODO"<<endl;

cout<<"5. FINALIZAR"<<endl;
OMAR GALVEZ ÁLVAREZ LI

cout<<"Elije una opcion"<<endl;

cin>>op;

clrscr();

switch (op){

case 1:

char Info[8][2]={{"G"},{"I"},{" "},{"T"},{"O"},{"A"},

{" "},{"T"}};

int Indice[8]={5,7,6,1,-999,3,-999,4};

int Inicio=0,Disp=2;

cout<<"El Recorrido es:\n";

Recorrido(Info,Indice,Inicio,Disp);

getch();

void Recorrido(char Info[8][2],int Indice[8],int Inicio,int Disp)

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;

cout<<"Que Numero deseas buscar?";

cin>>Elemento;

Res=Busqueda(Info,Indice,Inicio,Disp,Elemento);
OMAR GALVEZ ÁLVAREZ LI

if(Res==-999)

cout<<"Dato No Encontrado...";

getch();

int Busqueda(int Info[8],int Indice[8],int Inicio,int Disp,int Elemento)

int Apuntador=Inicio;

while(Apuntador!=-999)

if(Elemento==Info[Apuntador])

cout<<"Numero "<<Info[Apuntador]<<" encontrado...";

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);

cout<<"Que Numero deseas Insertar?";

cin>>Elemento;
OMAR GALVEZ ÁLVAREZ LI

Res=InsOrd(Info,Indice,Inicio,Elemento);

InsNd(Info,Indice,Inicio,Disp,Elemento,Res);

getch();

void Recorrido(int Info[8],int Indice[8],int Inicio,int Disp)

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 InsOrd(int Info[8],int Indice[8],int Inicio,int Elemento)

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);

cout<<"Que Numero deseas Insertar?";

cin>>Elemento;

Res=InsOrd(Info,Indice,Inicio,Elemento);

InsNd(Info,Indice,Inicio,Disp,Elemento,Res);

getch();

void Recorrido(int Info[8],int Indice[8],int Inicio,int Disp)

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 InsOrd(int Info[8],int Indice[8],int Inicio,int Elemento)

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:

cout<<"Esa Opcion no Existe, Solo la 1ra y la 2da"<<endl;

break;

getch();

cout<<" "<<endl;

cout<<" "<<endl;

}while(1==1);

También podría gustarte