You are viewing a single comment's thread. Return to all comments →
Here is mine. It has also null check.
public static void plusMinus(List arr) { double positiveQuantity, negativeQuantity, zeroQuantity = 0;
foreach(var item in arr){ if(item > 0) positiveQuantity++; else if(item < 0) negativeQuantity++; else zeroQuantity++; } int length = arr.Count; Console.WriteLine(positiveQuantity>0?(positiveQuantity/length):0); Console.WriteLine(negativeQuantity>0?(negativeQuantity/length):0); Console.WriteLine(zeroQuantity>0?(zeroQuantity/length):0); }
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 →
Here is mine. It has also null check.
public static void plusMinus(List arr) { double positiveQuantity, negativeQuantity, zeroQuantity = 0;