Menghitung Mean dan Mencari Median C# Posted by Unknown on January 30, 2015 Get link Facebook X Pinterest Email Other Apps using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace median { class Program { static void Main(string[] args) { int data; int total = 0; int[] bil = new int[0]; Console.Write("Banyak Data = "); data = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(); for (int i = 1; i <= data; i++) { Array.Resize(ref bil, bil.Length + 1); Console.Write("bilangan ke-{0} = ", i); bil[bil.GetUpperBound(0)] = Convert.ToInt32(Console.ReadLine()); } Console.WriteLine(); Array.Sort(bil); Console.Write("Data setelah Diurutkan : "); foreach (int i in bil) Console.Write("{0} ",i); Console.WriteLine(); Console.Write("Median = {0}", bil[bil.Length / 2]); for (int i = 0; i < bil.Length; i++) { total += bil[i]; } Console.WriteLine(); Console.Write("Mean = {0}",(float) total/data); Console.ReadKey(); } } } Comments
Comments
Post a Comment