Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace System;
  4. using namespace std;
  5.  
  6. void Alumnos(int *&n) {
  7. do {
  8. cout << "Ingrese el numero de alumnos: ";
  9. cin >> *n;
  10. } while (*n < 1);
  11. cout << endl;
  12. }
  13.  
  14. void Notas(int *n, int *notas) {
  15. Random x;
  16. cout << "(esto no estaba en el ejercicio, pero para que corrobores: ";
  17. for (short i = 1;i <= *n;i++) {
  18. notas[i] = x.Next(0, 20 + 1);
  19. cout << notas[i] << " ";
  20. }
  21. cout << ")" << endl;
  22. }
  23.  
  24. void Promedio(int *n, int *notas, float *pro) {
  25. short i; *pro = 0;
  26. for (i = 1;i <= *n;i++) {
  27. (*pro) += notas[i];
  28. }
  29. (*pro) /= i;
  30. cout << "El promedio de la notas es " << *pro << endl;
  31. }
  32.  
  33. void Moda(int *n, int *notas, int *mod) {
  34. cout << "La moda es mas dificil y toma tiempo. " << endl;
  35. }
  36.  
  37. void Mayor(int *n, int *notas, int *max) {
  38. *max = 0;
  39. for (short i = 1;i <= *n;i++) {
  40. if (*max < notas[i]) *max = notas[i];
  41. }
  42. cout << "La nota maxima de los alumnos es: " << *max << endl;
  43. }
  44.  
  45. void Menor(int *n, int *notas, int *men) {
  46. *men = 21;
  47. for (short i = 1;i <= *n;i++) {
  48. if (*men > notas[i]) *men = notas[i];
  49. }
  50. cout << "La nota minima de los alumnos es: " << *men << endl;
  51. }
  52.  
  53. void main() {
  54. int *n; n = new int;
  55. int *notas; notas = new int;
  56. float *pro; pro = new float;
  57. int *mod; mod = new int;
  58. int *max; max = new int;
  59. int *men; men = new int;
  60.  
  61. Alumnos(n);
  62. Notas(n, notas);
  63. Promedio(n, notas, pro);
  64. Moda(n, notas, mod);
  65. Mayor(n, notas, max);
  66. Menor(n, notas, men);
  67.  
  68.  
  69.  
  70. cout << endl;
  71. system("pause>0");
  72. delete[] n, notas, pro, mod, max, men;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement