#include <iomanip>
#include <windows.h>
#include<iostream>
#include <cstdio>
#include<cstdlib>
#include <conio.h>
#include<string.h>
#define max 500
//..........................................................................//
//..........................................................................//
using namespace std;
//..........................................................................//
//..........................................................................//
/* definicion de los registros para la estructura */
struct nodo{
char nombre[max];
char caracteristicas[max];
int codigo;
int nota1;
int nota2;
int nota3;
int nota_del_proyecto;
struct nodo *sgte;
};
typedef struct nodo *lista;
//..........................................................................//
//..........................................................................//
/* definicion de los registros para la estructura */
/* especificacion de modulos */
void insertalinicio(lista &q,struct nodo k) ;
//..........................................................................//
//..........................................................................//
//Funcion Gotoxy
void gotoxy(int x,int y)
{
HANDLE hStdout;
COORD pos;
pos.X=x-1;
pos.Y=y-1;
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
if(hStdout == INVALID_HANDLE_VALUE)
return;
SetConsoleCursorPosition(hStdout,pos);
}
//..........................................................................//
//..........................................................................//
void ingreso__alumno(struct nodo emp,lista &q)
{
system("cls");
cout<<"\n\n\n\n\n\n\n\n\n\n\n\t\t\tINGRESE LOS DATOS DEL ALUMNO "<<endl;
cout<<"\t\t\t---------------------------------"<<endl;
cout<<"\t\t\t -----------------------------"<<endl;
getch();
system("cls");
cin.ignore(100, '\n');
cout<<"---------------------------------------"<<endl;
cout<<" NORMBRE Y APELLIDO DEL ALUMNO "<<endl;
cout<<"---------------------------------------"<<endl;
gets( emp.nombre );
cout<<" NOTAS "<<endl;
cout<<"-------------------------------"<<endl;
cout<<" NOTA___1 "<<endl;
cin>>emp.nota1;
cout<<"-------------------------------"<<endl;
cout<<" NOTA___2 "<<endl;
cin>>emp.nota2;
cout<<"-------------------------------"<<endl;
cout<<" NOTA___3 "<<endl;
cin>>emp.nota3;
cout<<"-------------------------------"<<endl;
cout<<" NOTA___DEL___PROYECTO "<<endl;
cin>>emp.nota_del_proyecto;
cin.ignore(100, '\n');
cout<<"-------------------------------"<<endl;
cout<<" CARACTERISTICAS DEL ALUMNO "<<endl;
cout<<"------------------------------"<<endl;
cin.get(emp.caracteristicas, max);
cout<<" CODIGO DEL ALUMNO "<<endl;
cout<<"------------------------------"<<endl;
cin >> emp.codigo;
insertalinicio(q,emp);
}
void insertalinicio(lista &q,struct nodo k) //inserta los datos recibidos de la funcion->ingreso producto
{ //
lista w=new(struct nodo);//creacion del nodo
k.sgte=q; //insertar al inicio de cada elemnto
*w=k; //alamcenar el nodo en un array temporal
q=w;
}
void pantallaso(lista q)
{
int i=1,nota__1,nota__2,nota__3,nota__4;
system("cls"); //limiar pantalla para cada llamada de la funcion
if (q == NULL)
{ printf("\n LA LISTA ESTA VACIA \n");
printf(" enter para terminar....");
system("pause");
}
cout<<"\t\t\t---------------------"<<endl;
cout<<"\t\t\tDATOS DE LOS ALUMNOS"<<endl;
cout<<"\t\t\t----------------------"<<endl;
while(q!=NULL)
{
cout<<"NOMBRE DEL ALUMNO................."<<q->nombre<<endl;
cout<<"CARACTERISTICAS DEL ALUMNO........"<<q->caracteristicas<<endl;
cout<<"CODIGO.............................."<<q->codigo<<endl;
nota__1=q->nota1;
cout<<"NOTA__1.............................."<<nota__1<<endl;
nota__2=q->nota2;
cout<<"NOTA__2.............................."<<nota__2<<endl;
nota__3=q->nota3;
cout<<"NOTA__3.............................."<<nota__3<<endl;
nota__4=q->nota_del_proyecto;
cout<<"NOTA__DEL__PROYECTO.............................."<<nota__4<<endl;
cout<<"PROMEDIO.............................."<<(nota__1+nota__2+nota__3+nota__4)/4.0<<endl;
q=q->sgte;
i++;cout<<"\nPRESIONE ENTER PARA CONTINUAR..."<<endl;
cout<<endl;
system("pause");
}
}
//..........................................................................//
//..........................................................................//
int buscar(lista q,int valor)
{
int c=1; // ingresamos desde la posicion 1
while(q!=NULL)
if(q->codigo==valor)
{
return c; //retorna c hasta que llege a NULL
}
else
{
c++;
q=q->sgte;
}
return 0; //retorna 0 cuando no encuentra el codigo en la lista
}
//..........................................................................//
//..........................................................................//
void menu(lista q)
{
struct nodo emp;
int opcion,valor,k=0,t;
system("cls");
printf("\n\n\t\t\t* * * * * MENU DE OPCIONES * * * * *");
printf("\n\t\t---------------------------------------------------");
printf("\n\t\t\t BASE DE DATOS DE ALUMNOS ");
printf("\n\t\t-------------------------------------------------\n\n\n\n");
printf("\t\t\t\t (1) AGREGAR ALUMNO \n");
printf("\t\t\t\t (2) REPORTE \n");
printf("\t\t\t\t (3) BUSCAR ALUMNO POR CODIGO \n");
printf("\t\t\t\t (4) SALIR ........ ");
printf("\n ELIGE UNA OPCION: ");
scanf("%d", &opcion);
while (opcion != 5)
{ switch(opcion)
{ case 1:
ingreso__alumno(emp,q);
break;
case 2: pantallaso(q);
break;
case 3:
system("CLS");
cout<<"\n\t\tDIGITE EL CODIGO DEL ALUMNO A BUSCAR\n"<<endl;
cin>>valor;
t=buscar(q,valor);
if(t>0)
{
cout<<"SE ENCUENTRA EL CODIGO DEL ALUMNO"<<endl;
}
if(t==0)
{
cout<<"NO SE ENCUENTRA EL CODIGO DEL ALUMNO"<<endl;
}
getch();
break;
case 4:
exit( 0 );
default : printf("\n opcion no permitida.....");
printf("\n enter para continuar....");
getch();
}
menu(q);
printf("\n\n ELIGE UNA OPCION: ");
scanf("%d", &opcion);
}
printf("\n fin del preograma....\n");
printf(" enter para terminar....");
getch();
}
//..........................................................................//
//..........................................................................//
int main()
{
system("color 1b");
system("cls");
printf("\n\n\n\n\n\n\n\n\n\n\t ...............loading...................");//texto de bienvenida
printf("\n\t ---------------------------------------------------------------");
printf("\n\t ---------------------------------------------------------");
getch();
system("cls");//limpiar pantalla
lista q=NULL;
menu(q);//menu de opciones
}
//..........................................................................//
//..........................................................................//