Advertisement
s00rk

C++ Ruben

Sep 10th, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.68 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. struct ALUMNO{
  6.     char nombre[50];
  7.     int nota1;
  8.     int nota2;
  9.     int nota3;
  10.     int total;
  11. };
  12.  
  13. void LeerNotas(ALUMNO Al[], int tam)
  14. {
  15.     if(tam < 1)
  16.     {
  17.         cout << "El arreglo es menor a 1" << endl;
  18.         return;
  19.     }
  20.     for(int x = 0; x < tam; x++)
  21.     {
  22.         cout << "Nombre del Alumno: ";
  23.         cin >> Al[x].nombre;
  24.         cout << "Nota No.1: ";
  25.         cin >> Al[x].nota1;
  26.         cout << "Nota No.2: ";
  27.         cin >> Al[x].nota2;
  28.         cout << "Nota No.3: ";
  29.         cin >> Al[x].nota3;
  30.         Al[x].total = (Al[x].nota1+Al[x].nota2+Al[x].nota3)/3;
  31.     }
  32.     cout << endl << endl;
  33. }
  34.  
  35. void MostrarMayorNota(ALUMNO Al[], int tam)
  36. {
  37.     if(tam < 1)
  38.     {
  39.         cout << "El arreglo es menor a 1" << endl;
  40.         return;
  41.     }
  42.     int mayor = Al[0].total, menor = Al[0].total, Mayor = 0, Menor = 0;
  43.     int mayorNota2 = Al[0].nota2, MayorNota2 = 0;
  44.  
  45.     for(int x = 1; x < tam; x++)
  46.     {
  47.         if(Al[x].total > mayor)
  48.         {
  49.             mayor = Al[x].total;
  50.             Mayor = x;
  51.         }else if(Al[x].total < menor){
  52.             menor = Al[x].total;
  53.             Menor = x;
  54.         }
  55.         if(Al[x].nota2 > mayorNota2)
  56.         {
  57.             mayorNota2 = Al[x].nota2;
  58.             MayorNota2 = x;
  59.         }
  60.     }
  61.     cout << "El Alumno con mayor Nota es: " << Al[Mayor].nombre << " con un promedio de: " << mayor << endl;
  62.     cout << "El Alumno con menor Nota es: " << Al[Menor].nombre << " con un promedio de: " << menor << endl << endl;
  63.     cout << "El Alumno con mayor Nota en el corte 2 es: " << Al[MayorNota2].nombre << " con una nota de: " << mayorNota2 << endl;
  64. }
  65.  
  66. int main()
  67. {
  68.     int tam = 0;
  69.     ALUMNO *Alumno;
  70.    
  71.     cout << "Total de Alumnos: ";
  72.     cin >> tam;
  73.     Alumno = new ALUMNO[tam];
  74.  
  75.     LeerNotas(Alumno, tam);
  76.     MostrarMayorNota(Alumno, tam);
  77.  
  78.     cin.get();cin.get();
  79.     return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement