#include #include #include #include #include #include #include struct alum { struct alum *siguiente; int control; char nom[40]; float prom; struct alum *anterior; }; struct alum *nuevoalumno(); void altas(); void bajas(struct alum **cab, struct alum **fin); void consultas(struct alum *cab); struct alum *cabecera, *final, *inicio; void main () { char opc; cabecera=final=inicio; do { clrscr (); gotoxy(30,9); cout<<"1. Insertar"; gotoxy(30,10); cout<<"2. Eliminar"; gotoxy(30,11); cout<<"3. Consultas"; gotoxy(30,12); cout<<"4. Salir"; gotoxy(30,14); cout<<" Elige la Opcion --> "; fflush (stdin); opc=getchar(); clrscr (); switch (opc) { case '1': altas(); break; case '2': bajas(&cabecera,&final); break; case '3': consultas(cabecera); break; case '4': break; } }while (opc!='4'); } void altas () { struct alum *p; char nombre[40]; int nc; float pr; int i; p=nuevoalumno(); int temp; clrscr (); gotoxy(10,5); cout<<"Dame el Numero de Control: "; fflush(stdin); cin>>nc; if(nccontrol) { temp=p->control; p->control=nc; p->siguiente++; p->control=temp; } p->control=nc; gotoxy (10,7); cout<<"DAME EL NOMBRE: "; fflush(stdin); gets(nombre); for(i=0;inom[i]=nombre[i]; gotoxy (10,9); cout<<"DAME EL PROMEDIO: "; fflush(stdin); cin>>pr; p->prom=pr; p->siguiente++; } void consultas (struct alum *p) { int band=0; char opc; int x; clrscr (); cout<<"\N Dame el numero de Control: "; fflush (stdin); cin>>x; while(p!=inicio) { if(p->control==x) { band=1; gotoxy (10,5); printf ("Nombre: %s",p->nom); gotoxy (10,7); cout<<"Num. Control: "<control; gotoxy (10,9); cout<<"Promedio: "<prom; } p=p->siguiente; } if(band==0) cout<<"\n El numero de Control no Existe"; getch (); } struct alum *nuevoalumno() { return((struct alum *)malloc (sizeof(struct alum))); // } void bajas (struct alum **cab, struct alum **fin) { struct alum *p, *f; int x; p = *cab; cout<<"\n Dame numero de control: "; fflush (stdin); cin>>x; while (p !=inicio && (p->control!=x)) { p= p->siguiente; } if (p==inicio) { cout<<"El dato no existe en lista \n"; cout<<"\n precione una tecla para continuar. . ."; getch(); } else { if(p->anterior!=inicio) p -> anterior -> siguiente= p->siguiente; else *cab=p->siguiente; if(p->siguiente!=inicio) { p ->siguiente ->anterior= p->anterior; } else *fin=p->anterior; free(p); } }