Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <conio.h>
- using namespace std;
- // estructuras
- struct nombre
- {
- char n1 [50];
- char n2 [50];
- };
- struct apellido
- {
- char ap1[50];
- char ap2[50];
- };
- struct practica
- {
- char materia [4][50];
- float promedio [4];
- float promF;
- };
- struct alumnos
- {
- nombre nom;
- apellido ape;
- int cod;
- };
- struct general
- {
- alumnos a;
- practica p;
- };
- //////////////// Funciones
- void ingresar (general x[], int &na, int &mat)
- {
- cout << "\n\t INGRESE EL NUMERO DE ESTUDIANTES : "; cin >> na;
- cout << "\n\t INGRESE EL NUMERO DE MATERIAS: "; cin >> mat;
- system ("cls");
- for (int i = 0 ; i < na ; i++)
- {
- system ("cls");
- /////// ALUMNOS
- cout << "\n\tNOMBRE (1): "; cin >> x[i].a.nom.n1;
- cout << "\n\tNOMBRE (2): "; cin >> x[i].a.nom.n2;
- cout << "\n\tAPELLIDO (1):";cin >> x[i].a.ape.ap1;
- cout << "\n\tAPELLIDO (2):";cin >> x[i].a.ape.ap2;
- cout << "\n\tCODIGO:"; cin >>x[i].a.cod;
- system ("cls");
- /////// MATERIAS
- for (int j =1 ; j <= mat ; j ++)
- {
- cout << "\n\tMATERIA "<<j<<": "; cin >> x[i].p.materia[j];
- cout << "\n\tPROMEDIO "<<j<<": "; cin >> x[i].p.promedio[j];
- x[i].p.promF = (x[i].p.promF) + (x[i].p.promedio[j]);
- }
- }
- }
- void consultar (general x[],int na, int mat)
- {
- system ("cls");
- int cd;
- int b = 0;
- float promedioF=0;
- cout << "INGRESE EL CODIGO DEL ESTUDIANTE: ";
- cin >>cd;
- for (int i = 0 ; i < na ; i++)
- {
- if (cd == x[i].a.cod)
- {
- b=1;
- /////// ALUMNOS
- cout << "\n\t\t DATOS DE "<<x[i].a.nom.n1;
- cout << "\n\tNOMBRE (1): "<<x[i].a.nom.n1;
- cout << "\n\tNOMBRE (2): "<<x[i].a.nom.n2;
- cout << "\n\tAPELLIDO (1):"<<x[i].a.ape.ap1;
- cout << "\n\tAPELLIDO (2):"<<x[i].a.ape.ap2;
- cout << "\n\tCODIGO:"<<x[i].a.cod;
- /////// MATERIAS
- for (int j =1 ; j <= mat ; j ++)
- {
- cout << "\n\n\tMATERIA : "<<x[i].p.materia[j];
- cout << "\n\n\tPROMEDIO: "<<x[i].p.promedio[j];
- promedioF =x[i].p.promF / mat;
- }
- cout << "\n\n\tPROMEDIO FINAL: "<<promedioF;
- cout << "\n\n\n";
- }
- }
- if (b==0)
- {
- cout <<"\n\t EL USUARIO NO CONSTA EN LA BASE DE DATOS";
- }
- }
- void imprimir (general x[] , int na , int mat)
- {
- system ("cls");
- int comprobante;
- float promedioF=0;
- cout <<"inserte el codigo del alumno a buscar:";
- cin>>comprobante;
- for (int i = 0 ; i < na ; i++)
- {
- if(comprobante==x[i].a.cod){
- /////// ALUMNOS
- cout << "\n\tNOMBRE (1): "<<x[i].a.nom.n1;
- cout << "\n\tNOMBRE (2): "<<x[i].a.nom.n2;
- cout << "\n\tAPELLIDO (1):"<<x[i].a.ape.ap1;
- cout << "\n\tAPELLIDO (2):"<<x[i].a.ape.ap2;
- cout << "\n\tCODIGO:"<<x[i].a.cod;
- /////// MATERIAS
- for (int j =1 ; j <= mat ; j ++)
- {
- cout << "\n\n\tMATERIA : "<<x[i].p.materia[j];
- cout << "\n\n\tPROMEDIO: "<<x[i].p.promedio[j];
- promedioF =x[i].p.promF / mat;
- }
- cout << "\n\n\tPROMEDIO FINAL: "<<promedioF;
- cout << "\n\n\n";
- }}
- }
- int main ()
- {
- /// VARIABLES
- general x[4];
- int op;
- int na;
- int mat;
- ////
- MENU:
- system ("cls");
- cout <<"\n\t==========MENU DE OPCIONES==========\n";
- cout <<"\n\t 1.INGRESAR.";
- cout <<"\n\t 2.CONSULTAR.";
- cout <<"\n\t 3.IMPRIMIR.";
- cout <<"\n\t 4.SALIR.";
- do{cout <<"\n\n\t INGRESE UNA OPCION: ";cin >> op;}while (op < 1 ||op > 4);
- ///////////// DECLARACION DE MENU ///////////////////////
- if (op ==1)
- {
- ingresar (x,na,mat);
- goto MENU;
- }
- else if (op ==2)
- {
- consultar (x,na,mat);
- getch ();
- goto MENU;
- }
- else if (op ==3)
- {
- imprimir (x,na,mat);
- getch ();
- goto MENU;
- }
- else
- {
- goto FIN;
- }
- FIN:
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement