You are viewing a single comment's thread. Return to all comments →
in c#: public static void plusMinus(List arr) { double len = arr.Count;
long zeroCount = arr.Where(x => x == 0).Count(); long positiveCount = arr.Where(x => x > 0).Count(); long negativeCount = arr.Where(x => x < 0).Count(); double zeroRatio = (double)zeroCount / len; double positiveRatio = (double)positiveCount / len; double negativeRatio = (double)negativeCount / len; Console.WriteLine(positiveRatio.ToString("F6")); Console.WriteLine(negativeRatio.ToString("F6")); Console.WriteLine(zeroRatio.ToString("F6")); }
Seems like cookies are disabled on this browser, please enable them to open this website
Plus Minus
You are viewing a single comment's thread. Return to all comments →
in c#: public static void plusMinus(List arr) { double len = arr.Count;