Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- struct ALUMNO{
- char nombre[50];
- int nota1;
- int nota2;
- int nota3;
- int total;
- };
- void LeerNotas(ALUMNO Al[], int tam)
- {
- if(tam < 1)
- {
- cout << "El arreglo es menor a 1" << endl;
- return;
- }
- for(int x = 0; x < tam; x++)
- {
- cout << "Nombre del Alumno: ";
- cin >> Al[x].nombre;
- cout << "Nota No.1: ";
- cin >> Al[x].nota1;
- cout << "Nota No.2: ";
- cin >> Al[x].nota2;
- cout << "Nota No.3: ";
- cin >> Al[x].nota3;
- Al[x].total = (Al[x].nota1+Al[x].nota2+Al[x].nota3)/3;
- }
- cout << endl << endl;
- }
- void MostrarMayorNota(ALUMNO Al[], int tam)
- {
- if(tam < 1)
- {
- cout << "El arreglo es menor a 1" << endl;
- return;
- }
- int mayor = Al[0].total, menor = Al[0].total, Mayor = 0, Menor = 0;
- int mayorNota2 = Al[0].nota2, MayorNota2 = 0;
- for(int x = 1; x < tam; x++)
- {
- if(Al[x].total > mayor)
- {
- mayor = Al[x].total;
- Mayor = x;
- }else if(Al[x].total < menor){
- menor = Al[x].total;
- Menor = x;
- }
- if(Al[x].nota2 > mayorNota2)
- {
- mayorNota2 = Al[x].nota2;
- MayorNota2 = x;
- }
- }
- cout << "El Alumno con mayor Nota es: " << Al[Mayor].nombre << " con un promedio de: " << mayor << endl;
- cout << "El Alumno con menor Nota es: " << Al[Menor].nombre << " con un promedio de: " << menor << endl << endl;
- cout << "El Alumno con mayor Nota en el corte 2 es: " << Al[MayorNota2].nombre << " con una nota de: " << mayorNota2 << endl;
- }
- int main()
- {
- int tam = 0;
- ALUMNO *Alumno;
- cout << "Total de Alumnos: ";
- cin >> tam;
- Alumno = new ALUMNO[tam];
- LeerNotas(Alumno, tam);
- MostrarMayorNota(Alumno, tam);
- cin.get();cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement