Proyecto Final Con Listas Enlazadas En C

Páginas: 7 (1520 palabras) Publicado: 14 de julio de 2011
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//-----DECLARACIONES----
struct registros
{

char institucion[20];
};

typedef struct nodolista
{

struct registros reg;
struct nodolista * sig;
} nodolista;
nodolista * primero,*ultimo;

struct direccion
{
char calle [30];
int numero;
};

typedef struct nodoarbol
{
char descripcion[30];char nombre[30];
char apellido[30];

int estado;
struct direccion direccion;
struct nodoarbol * izq;
struct nodoarbol * der;

} nodoarbol;

typedef struct celda
{
char institucion;
struct nodoarbol * solicitud;
} celda;

//------FIN DE LAS ESTRUCTURAS------
//------INICIALIZARLAS---------

nodolista * iniclista()
{
return NULL;
}

nodoarbol * inicarbol()
{return NULL;
}

//--------FIN DE LA INICIALIZACION-------
//--------CREAR NODOS LISTAS Y ARBOLES-----

nodolista * crearnodoslista(char institucion[20])
{

nodolista * aux;
aux = (nodolista *) malloc (sizeof (nodolista));
strcpy (aux->reg.institucion,institucion);
aux->sig=NULL;
return aux;
}

nodoarbol * crearnodosarbol(char descripcion[30],char nombre[30],charapellido[30],int estado,char calle[30],int numero)
{
nodoarbol * aux=(nodoarbol *)malloc(sizeof (nodoarbol));
strcpy(aux->descripcion,descripcion);
strcpy(aux->nombre,nombre);
strcpy(aux->apellido,apellido);

aux->estado=estado;
strcpy(aux->direccion.calle,calle);
aux->direccion.numero=numero;
aux->der=NULL;
aux->izq=NULL;
return aux;
}
//---------FIN DE LACREACION DE LOS NODOS----
//---------CODIGOS DE LAS LISTAS------

void agregarprincipio(char* institucion)
{
nodolista *temp;

temp=( nodolista *)malloc(sizeof( nodolista));
strcat(institucion, "\0");
strcpy(temp->reg.institucion, institucion);

if (primero == NULL)
{
primero = temp;
primero->sig = NULL;
}
else
{
temp->sig = primero;
primero = temp;
}
}nodolista * agregarfinal (char * institucion)
{

nodolista *temp1, *temp2;

temp1=( nodolista *)malloc(sizeof(nodolista));
strcat(institucion, "\0");
strcpy(temp1->reg.institucion, institucion);

temp2 = primero;

if(primero == NULL)
{
primero = temp1;
primero->sig = NULL;
}
else
{
while(temp2->sig != NULL)
temp2 = temp2->sig;

temp1->sig = NULL;temp2->sig = temp1;
}
}
/*
nodolista * buscarultimo(nodolista * lista)
{
nodolista *seg=lista;
if(seg!=NULL)

while (seg->sig!=NULL)
{
seg=seg->sig;
}
return seg;
}
*/
int buscarenlista(char* institucion)
{
nodolista * actual = primero;
int encontrado = 0;
while (actual)
{
int result = strcmp(institucion, actual->reg.institucion);
if (result == 0){
encontrado = 1;
break;
}
actual = actual->sig;
}
return encontrado;
}
nodolista * cargarlista(celda celda[5],nodolista * lista)
{
// celda celda[5];
nodolista * aux;
struct registros reg;
char institucion [20];
char i='s';
int pos;

while(i!='n')
{
printf("---CARGAR LOS DATOS DE LAS INSTITUCIONES---\n");
printf("Institucion:");
scanf("%s",institucion);for (pos = 0; pos < 20; pos++)
{
if (reg.institucion[pos] == 1)
reg.institucion[pos] = 0;
}
fflush(stdin);
aux=crearnodoslista(institucion);
lista=agregarfinal(institucion);

int existeinstitucion=buscarenlista(institucion);
if (existeinstitucion == 0);
agregarfinal(institucion);
printf("desea seguir ingresando? (s/n) \n");
i=getchar();
return lista;

}
}
/*int existecelda(celda a[5],char institucion[30], int x)
{
int flag=0;
if (strcmp(a[x].institucion,institucion)==0)
{
flag=1;
}
else
{
(strcmp(a[x].institucion,institucion)==1) ;

}

return flag;

}*/

int existeinstitucion(celda celda[5],nodolista * lista)
{
nodolista * aux;
char institucion[20];

int flag=0;
while (aux!=NULL && flag!=1)
{
if...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Listas enlazadas en C++
  • Lista Enlazada En C
  • Lista simplemente enlazada lenguaje c
  • Listas Enlazadas C++ (Todas Sus Operaciones)
  • Proyecto Final C
  • Listas Enlazadas en C
  • Listas enlazadas
  • Listas Enlazadas

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS