![]() |
C# Ortalamayı bozan kayıtları çıkarma |
Post Reply ![]() |
|
Author | |
emrebademci ![]() Newbie ![]() Joined: 03 Aralık 2018 Status: Offline Points: 2 |
![]() ![]() ![]() ![]() ![]() Posted: 03 Aralık 2018 at 23:03 |
Arkadaşlar merhaba,
C# ile bir list teki değerlerin ortalamasını aldıktan sonra bu ortalamayı bozan kayıtları çıkarmak istiyorum, Örneğin; 10 11 10 12 13 50 51 Burada tüm sayıların ortalamasını aldığımda 50 ve 51 ortalamayı diğer sayılara göre daha çok değiştireceği için 50 ve 51 çıkarmaya çalışıyorum, Aşağıdaki konsol uygulamasında ortalama ve standart sapma var ama yukarıdaki gibi bir şey nasıl yazabilirim ? int i = 1; Console.WriteLine("Sayı eklemesini durdurmak için sayı yerine : ' * ' tuşuna basıp enterlayın.\n"); List<int> numbers = new List<int>(); int sum = 0; while (true) { Console.Write(i + ". sayıyı girin : "); string read = Console.ReadLine(); if (read.Equals("*")) break; numbers.Add(int.Parse(read)); sum += int.Parse(read); i++; } double deviation = 0.0; double mean = sum / numbers.Count; for (i = 0; i < numbers.Count; i++) { var _a = numbers; var _b = Math.Pow((_a - mean), 2); deviation += _b; } deviation = deviation / numbers.Count; Console.WriteLine("Topluluk ortalaması : " + mean + "\nTopluluk standart sapması : " + deviation); Console.ReadKey(); |
|
![]() |
Post Reply ![]() |
|
Tweet
|
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |