Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <array>
  3. #include <cstdlib>
  4. using namespace std;
  5.  
  6. const unsigned int MAX_ALUMNOS = 10;
  7.  
  8. typedef array <double, MAX_ALUMNOS> TNotas;
  9. typedef unsigned int TNatural;
  10.  
  11.  
  12. void LeerNotas(TNotas &notas);
  13.  
  14. void EscribirNotas(const TNotas &notas);
  15.  
  16. double MediaAritmetica(const TNotas &notas);
  17.  
  18. TNatural MayorMedia(const TNotas &notas);
  19. TNatural MenoresMedia (const TNotas &notas);
  20.  
  21.  
  22.  
  23. int main (){
  24.  
  25.  
  26.     TNotas notas;
  27.  
  28.     cout << "Introduce Notas" << endl;
  29.  
  30.     LeerNotas(notas);
  31.  
  32.     cout << "Las notas son: " << endl;
  33.  
  34.     EscribirNotas(notas);
  35.  
  36.     cout << endl << "La nota media es: " << MediaAritmetica(notas) << endl;
  37.     cout << endl << "Hay " << MayorMedia(notas) << " notas mayores de la media" << endl;
  38.     cout << endl << "Hay " << MenoresMedia(notas) << " notas menores que la media" << endl;
  39.  
  40.  
  41.  
  42. return 0;
  43.  
  44. }
  45.  
  46. void LeerNotas(TNotas &notas){
  47.  
  48.     for (unsigned int i=0; i < MAX_ALUMNOS; ++i){
  49.         cout << "Nota["<< i <<"]=" << endl;
  50.         cin >> notas[i];
  51.         cin.ignore();
  52.     }
  53. }
  54.  
  55.  
  56. void EscribirNotas(const TNotas &notas){
  57.  
  58.     for (unsigned int i=0; i < MAX_ALUMNOS; ++i){
  59.         cout << "\tNota["<< i <<"]=" << notas[i] << endl;
  60.     }
  61.  
  62. }
  63.  
  64. double MediaAritmetica(const TNotas &notas){
  65.  
  66.     double Media = 0;
  67.  
  68.     for (unsigned int i=0; i < MAX_ALUMNOS; ++i){
  69.        Media = Media + notas[i];
  70.     }
  71.  
  72.     return Media/MAX_ALUMNOS;
  73. }
  74.  
  75. TNatural MayorMedia(const TNotas &notas){
  76.  
  77.     TNatural mayores = 0;
  78.     double media = MediaAritmetica(notas);
  79.  
  80.     for (unsigned int i=0; i < MAX_ALUMNOS; ++i){
  81.  
  82.     if (notas[i] > media){
  83.        ++mayores;
  84.     }
  85.  
  86.     }
  87.    return mayores;
  88. }
  89. TNatural MenoresMedia (const TNotas &notas){
  90.  
  91.     TNatural menores = 0;
  92.     double media = MediaAritmetica(notas);
  93.  
  94.     for (unsigned int i=0; i < MAX_ALUMNOS; ++i){
  95.  
  96.     if (notas[i] < media){
  97.        ++menores;
  98.     }
  99.  
  100.  
  101.     }
  102.    return menores;
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement