Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace tarea_Progra2
  8. {
  9. class Program
  10. {
  11. public static void llenar(int[] vec)
  12. {
  13. int i;
  14. for (i = 0; i < vec.Length; i++)
  15. {
  16. Console.WriteLine("[" + (i + 1 + "]: "));
  17. vec[i] = int.Parse(Console.ReadLine());
  18. }
  19. }
  20. public static void imprimir(int[] vec)
  21. {
  22. int i;
  23. Console.WriteLine();
  24. Console.WriteLine("Los datos son: ");
  25. for (i = 0; i < vec.Length; i++)
  26. {
  27. Console.WriteLine(vec[i]);
  28. }
  29. }
  30. public static float promedio(int[] vec)
  31. {
  32. int i, suma = 0;
  33. float promed;
  34. for (i = 0; i < vec.Length; i++)
  35. {
  36. suma = suma + vec[i];
  37. }
  38. promed = suma / vec.Length;
  39. Console.WriteLine("Promedio: " + promed);
  40. return promed;
  41. }
  42. public static int sobrevec(int[] vec, float promed)
  43. {
  44. int i, mayores = 0;
  45. for (i = 0; i < vec.Length; i++)
  46. {
  47. if ((float)vec[i] > promed)
  48. {
  49. mayores++;
  50. }
  51. }
  52. return mayores;
  53. }
  54. public static float centaje(int[] vec)
  55. {
  56. float prom = promedio(vec);
  57. int mayores = sobrevec(vec, prom);
  58. float pctj = 0;
  59. pctj = (mayores * 100) / vec.Length;
  60. Console.WriteLine("Porcentaje: "+ pctj+"%");
  61. return pctj;
  62. }
  63. static void Main(string[] args)
  64. {
  65. int n;
  66. int[] v;
  67. Console.WriteLine("Ingrese cantidad de Elementos");
  68. n = int.Parse(Console.ReadLine());
  69. v = new int[n];
  70. llenar(v);
  71. imprimir(v);
  72. float prom = promedio(v);
  73. sobrevec(v, prom);
  74. centaje(v);
  75. Console.ReadKey();
  76. }
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement