Lista Enlace Doble C++

Páginas: 2 (297 palabras) Publicado: 30 de marzo de 2014
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:

#include
#include
#include
using namespace std;
struct Node{
struct Node* Back;
int Info;
struct Node* Next;};
typedef struct Node* NodePtr;
NodePtr Inicio, Final, Nuevo;
NodePtr Aux, P;
NodePtr getNode(void){
NodePtr p;
p=(NodePtr)malloc(sizeof(struct Node));
if (p != 0)
p->Back = 0;
p->Next = 0;return(p);
}
void freeNode(NodePtr p){
free(p);
}
void Imprime(){
NodePtr Aux;
Aux = Inicio;
if (Aux != 0){
do{
cout Info Next;
}while (Aux != 0);
}
}
void CrearLista(int X){
if(Inicio == 0){
Nuevo = getNode();
if (Nuevo !=0)
{
Inicio = Nuevo;
Final = Nuevo;
Inicio->Info = X;
}
}
}
void AgregarFinal(int X){

58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:108:
109:
110:
111:
112:
113:
114:

Nuevo = getNode();
if (Nuevo != 0)
{
Nuevo->Info = X;
Final->Next = Nuevo;
Final = Nuevo;
}
}
void AgregarInicio(int X){
Nuevo = getNode();
if(Nuevo != 0)
{
Nuevo->Next = Inicio;
Inicio = Nuevo;
Inicio->Info = X;
}
}
void AgregarMedio( int X ){
Nuevo = getNode();
if (Nuevo != 0)
{
Nuevo->Next = Aux->Next;
Aux->Next = Nuevo;Nuevo->Info = X;
}
}

void BorrarNodo(){
int X;
int Bandera = 0; // No encontrado
gotoxy(10,15);
cout > X;
// Inicia el recorrido en la lista
Aux = Inicio;
P = Inicio; //
while( Aux != 0){
//if( X == Aux -> Info){ // el valor está en la lista
Bandera = 1;
if (Aux == Inicio && Aux -> Next == 0) // Solo hay un nodo
{
freeNode( Aux );
Inicio = 0;
Final = 0;
break;
}
else if ( Aux ==...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • doble enlace
  • Listas dobles
  • Estabilidad del enlace c−c
  • Listas c++
  • Listas en c#
  • Listas en c
  • Listas c++
  • Listas C++

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS