Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace tarea_Progra2
- {
- class Program
- {
- public static void llenar(int[] vec)
- {
- int i;
- for (i = 0; i < vec.Length; i++)
- {
- Console.WriteLine("[" + (i + 1 + "]: "));
- vec[i] = int.Parse(Console.ReadLine());
- }
- }
- public static void imprimir(int[] vec)
- {
- int i;
- Console.WriteLine();
- Console.WriteLine("Los datos son: ");
- for (i = 0; i < vec.Length; i++)
- {
- Console.WriteLine(vec[i]);
- }
- }
- public static float promedio(int[] vec)
- {
- int i, suma = 0;
- float promed;
- for (i = 0; i < vec.Length; i++)
- {
- suma = suma + vec[i];
- }
- promed = suma / vec.Length;
- Console.WriteLine("Promedio: " + promed);
- return promed;
- }
- public static int sobrevec(int[] vec, float promed)
- {
- int i, mayores = 0;
- for (i = 0; i < vec.Length; i++)
- {
- if ((float)vec[i] > promed)
- {
- mayores++;
- }
- }
- return mayores;
- }
- public static float centaje(int[] vec)
- {
- float prom = promedio(vec);
- int mayores = sobrevec(vec, prom);
- float pctj = 0;
- pctj = (mayores * 100) / vec.Length;
- Console.WriteLine("Porcentaje: "+ pctj+"%");
- return pctj;
- }
- static void Main(string[] args)
- {
- int n;
- int[] v;
- Console.WriteLine("Ingrese cantidad de Elementos");
- n = int.Parse(Console.ReadLine());
- v = new int[n];
- llenar(v);
- imprimir(v);
- float prom = promedio(v);
- sobrevec(v, prom);
- centaje(v);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement