/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
//PROYECTO 5.Guardar datos de alumnos de una escuela.
#include<iostream>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
using namespace std;
int main(){
//DECLARACIÓN DE VARIABLES
char nombre[21][50], apellido[21][50], nomMateria[5][30], mayor[30], menor[30];
float notas[21][5], suma[21][5], promAlumno[21], sumatotal = 0, promTotal = 0;
int max=0, min=999;
//ENTRADA DE DATOS
//INGRESANDO NOMBRES DE LAS 5 MATERIAS
for(int i=0; i<5; i++){
fflush(stdin);
cout<<"\nNombre de la materia "<<i+1<<": "; cin.getline(nomMateria[i],30,'\n');
}
//INGRESANDO NOMBRE Y APELLIDO DE CADA ALUMNO
for(int i=0; i<20; i++){
fflush(stdin);
cout<<"-----------------------------------Datos ALUMNO "<<i+1<<"-----------------------------------"<<endl;
cout<<"Nombre de alumno: "; cin.getline(nombre[i],50,'\n');
cout<<"Apellido de alumno: "; cin.getline(apellido[i],50,'\n');
//CONCATENANDO NOMBRE Y APELLIDO
strcat(nombre[i],apellido[i]);
}
//INGRESANDO NOTAS DE LAS 5 MATERIAS DE CADA ALUMNO
for(int i=0; i<20; i++){
cout<<" ALUMNO "<<i+1;
for(int j=0; j<5; j++){
fflush(stdin);
cout<<"/nNota de la materia "<<nomMateria[j]<<": "; cin>>notas[i][j];
suma[i][6] += notas[6][j];
}
cout<<"\n";
//CÁLCULO DE PROMEDIO DE CADA ALUMNO
promAlumno[i] = suma[i][6] / 5;
cout<<"\n";
}
//CÁLCULO DE PROMEDIO TOTAL
for(int i=0; i<20; i++){
sumatotal += promAlumno[i];
}
promTotal = sumatotal / 20;
//ENCONTRANDO EL MAYOR
for(int i=0; i<20; i++){
for(int j=0; j<5; j++){
if(notas[i][j] > max){
max = notas[i][j];
strcpy(mayor,nomMateria[i]);
}
}
}
//ENCONTRANDO EL MENOR
for(int i=0; i<20; i++){
for(int j=0; j<5; j++){
if(notas[i][j] < min){
min = notas[i][j];
strcpy(menor,nomMateria[i]);
}
}
}
//SALIDA DE DATOS
cout<<"//////////////////////////////////MOSTRANDO RESULTADO//////////////////////////////////"<<endl;
for(int i=0; i<20; i++){
cout<<"\n1. Nombre y apellido del alumno "<<i+1<<": "<<nombre[i]<<endl;
cout<<"2. Promedio general: "<<promAlumno[i]<<endl;
cout<<"3. Materia con mayor nota: "<<mayor<<" con "<<max<<endl;
cout<<"4. Materia con menor nota: "<<menor<<" con "<<min<<endl;
cout<<"____________________________________________________________________________________"<<endl;
}
cout<<"PROMEDIO GENERAL: "<<promTotal;
getch();
}