static void Main(string[] args) { double output; List <double> numbers = new List <double>(); string[] inputs = Console.ReadLine().Replace('.', ',').Split(Separator); int strlen = inputs.Length; double tmp = 0; for (int i = 0; i < strlen; i++) { if (inputs[i] != string.Empty) { if (!double.TryParse(inputs[i], out tmp)) { continue; } numbers.Add(tmp); } } double N = numbers.Count; double x_carka; tmp = 0; for (int i = 0; i < N; i++) { tmp = OwnMath.add(tmp, numbers[i]); } x_carka = OwnMath.mul(OwnMath.div(1, N), tmp); tmp = 0; for (int i = 0; i < N; i++) { tmp = OwnMath.add(tmp, OwnMath.pow(numbers[i], 2)); } output = OwnMath.sqrt(OwnMath.mul(OwnMath.div(1, OwnMath.sub(N, 1)), OwnMath.sub(tmp, OwnMath.mul(N, OwnMath.pow(x_carka, 2))))); Console.WriteLine(output); }
public void SubTest() { //check sub(double a, double b) Assert.AreEqual(10, OwnMath.sub(15.5, 5.5)); Assert.AreEqual(-10, OwnMath.sub(-15.5, -5.5)); }