Está en la página 1de 3

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:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct nodo{
struct nodo *ptr_a;
char nombre[25];
char apellido[25];
char direccion[40];
int edad;
char cedula[15];
struct nodo *ptr_s;
};
struct nodo *primero=NULL;
struct nodo *ultimo=NULL;
struct nodo *actual=NULL;
void
void
void
void

menu();
crear_nodos();
eliminar();
imprimir();

int main(){
int op;
do{
menu();
scanf("%d", &op);
switch(op){
case 1:
system("cls");
crear_nodos();
break;
case 2:
system("cls");
eliminar();
break;
case 3:
system("cls");
printf("\n *********Impresion de Datos**********\n");
imprimir();
break;
}
}while(op!=4);
}
void menu(){
printf("\n\t\t------------MENU------------\n");
printf("\n\t\t 1. Crear nodos
\n");
printf("\n\t\t 2. Eliminar
\n");
printf("\n\t\t 3. Imprimir
\n");
printf("\n\t\t 4. salir
\n");
printf("\t\t----------------------------\n");
printf("\n\t\t SELECCIONE UNA OPCION:\t");

56:
57:
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:

}
void crear_nodos(){
struct nodo *aux=NULL;
actual=NULL;
actual=(struct nodo *)malloc(sizeof (struct nodo));
actual->ptr_a=NULL;
printf("\n\t\t ~~~~~~DATOS DE USUARIO~~~~~~\n");
printf("\n \t Introduzca la cedula: ");
scanf("%s",actual->cedula);
printf("\n \t Introduzca el nombre: ");
scanf("%s",actual->nombre);
printf("\n \t Introduzca el apellido: ");
scanf("%s",actual->apellido);
printf("\n \t Introduzca la direccion: ");
scanf("%s",actual->direccion);
printf("\n \t Introduzca la edad: ");
scanf("%d",&actual->edad);
actual->ptr_s=NULL;
if (primero==NULL){
primero=actual;
ultimo=primero;
}else{
aux=ultimo;
ultimo=actual;
aux->ptr_s=actual;
actual->ptr_a=aux;
}
}
void imprimir(){
struct nodo *tem=NULL, *imp=NULL;
imp=primero;
do{
printf("\n \t---------DATOS DE USUARIO----------\n");
printf("\n \t CEDULA: %s", imp->cedula);
printf("\n \t NOMBRE: %s", imp->nombre);
printf("\n \t APELLIDO: %s", imp->apellido);
printf("\n \t DIRECCION: %s", imp->direccion);
printf("\n \t EDAD: %d", imp->edad);
printf("\n \t-----------------------------------\n");
tem=imp;
imp=imp->ptr_s;
}while(tem!=ultimo);
}
void eliminar(){
int cent=0;
int cont=0;
struct nodo *tem, *tem2, *tem3;
char ced[15];
tem=primero;
printf("\n Teclee la cedula de la persona a buscar:\t");
scanf("%s",ced);
//if(tem->cedula==ced){
while((ced != tem->cedula) && (tem != NULL)){

111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125: }
126:

tem=tem->ptr_s;
}
if (tem != NULL){
primero=tem->ptr_s;
tem->ptr_a=ultimo;
cent=1;
}
free(tem);
cont--;
if (cent==1){
printf("\nNodo Eliminado");
}else{
printf("\nNodo no Eliminado");
}

También podría gustarte