Título: Ayuda con listas enlazadas C++ solo para Masters jejejeje Publicado por: haven7 en 27 Junio 2012, 03:32 am Buenas noches necesito ayuda con este codigo necesito hacer un programa que manipule dos listas enlazadas . En cual la lista -A debe ingresar Codigo de -Estudiante, Nombre y la Cedula. Y la lista B donde se almacene Codigo de Estudiante, Codigo de Asignatura y La nota ....Debe tener un menu donde muestre Datos de los estudiantes, Captura de Notas y Credito de los estudiantes ....Gracias
#include<stdio.h> #include<conio.h> #include<alloc.h> #include<string.h> #include<stdlib.h> #include<ctype.h> #include<dos.h> #define null 0 struct estudiante { char nombre[50]; char telefono[25]; char mail[50]; }; struct info { char credito[50]; char codasignatura[25]; char notaasignatura[50]; }; struct nodo { struct estudiante dato1; struct info dato2; struct nodo *proximo; } struct nodo *creacola1(struct nodo *, struct estudiante); struct nodo *creacola2(struct nodo *, struct info); int colavacia1(struct nodo *); int colavacia2(struct nodo *); struct nodo *ingreso(); struct nodo *capturanota(); struct nodo *mostrar1(); struct nodo *mostrar2(); void main(){ clrscr(); int op; do{ clrscr(); gotoxy(31,4);printf("--MENU PRINCIPAL--"); gotoxy(30,6);printf("1.Ingresar Datos de Estudiante "); gotoxy(30,7);printf("2.Captura de Nota "); gotoxy(30,8);printf("3.Mostrar "); gotoxy(30,12);printf("0.Salir"); gotoxy(30,14);printf("Escoja una opcion "); op=getch(); clrscr(); switch(op){ case '1':ingreso(); break; case '2':capturanota(); break; case '3':mostrar1(); break; case '4':break; } }while(op!='0'); gotoxy(29,9);printf("!!GRACIAS USUARIO!!"); gotoxy(30,11);printf("LA VIDA ES DURA"); getch(); }//fin del menu principal struct nodo* ingreso(void) { struct nodo *pri1=NULL, *ult1=NULL; struct estudiante x1; printf("Ingrese nombre: "); gets(x1.nombre); while(strcmpi(x1.nombre,"fin")) { printf("Ingrese telefono: "); gets(x1.telefono); printf("Ingrese mail: "); gets(x1.mail); ult1=creacola1(ult1,x1); if(pri1==NULL) pri1=ult1; // Si es la 1º pasada pongo en pri el valor del primer nodo printf("Ingrese nombre: "); gets(x1.nombre); } return(pri1); } struct nodo* capturanota(void) { struct nodo *pri2=NULL, *ult2=NULL; struct info x2; printf("Ingrese credito: "); gets(x2.credito); while(strcmpi(x2.credito,"fin")) { printf("Ingrese asignatura: "); gets(x2.codasignatura); printf("Ingrese mail: "); gets(x2.codasignatura); ult2=creacola2(ult2,x2); if(pri2==NULL) pri2=ult2; // Si es la 1º pasada pongo en pri el valor del primer nodo printf("Ingrese credito de nota: "); gets(x2.credito); } return(pri2); } void mostrar1(struct nodo *pri1) { struct nodo *aux; while(pri1!=NULL) { printf("Nombre: %s - Telefono: %s - Mail: %s \n",pri1->dato1.nombre,pri1->dato1.telefono,pri1->dato1.mail); aux=pri1; pri1=(*pri1).proximo; free(aux); } getch(); } void mostrar2(struct nodo *pri2) { struct nodo *aux; while(pri2!=NULL) { printf("Nombre: %s - Telefono: %s - Mail: %s \n",pri2->dato2.credito,pri2->dato2.codasignatura,pri2->dato2.notaasignatura); aux=pri2; pri2=(*pri2).proximo; free(aux); } getch(); } struct nodo *nuevonodo() { struct nodo *p; p=(struct nodo *)malloc(sizeof(struct nodo)); if(p==NULL) { printf("Memoria RAM Llena"); getch(); exit(0); } return p; } struct nodo *creacola(struct nodo *ult1, struct estudiante x) { struct nodo *p; p=nuevonodo(); (*p).dato1=x; (*p).proximo=NULL; if(ult1!=NULL) (*ult1).proximo=p; // Si hay nodo anterior en prox pongo la direccion del nodo actual return p; } struct nodo *creacola(struct nodo *ult2, struct info x) { struct nodo *p; p=nuevonodo(); (*p).dato2=x; (*p).proximo=NULL; if(ult2!=NULL) (*ult2).proximo=p; // Si hay nodo anterior en prox pongo la direccion del nodo actual return p; } int colavacia1(struct nodo *pri1) { if(pri1==NULL) return 1; else return 0; } int colavacia2(struct nodo *pri2) { if(pri2==NULL) return 1; else return 0; } |