C#C
C#4y ago
shawski.

✅ runtime error

using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System;

class Result
{

    /*
     * Complete the 'plusMinus' function below.
     *
     * The function accepts INTEGER_ARRAY arr as parameter.
     */

    public static void plusMinus(List<int> arr)
    {
        int positive = 0;
        int negative = 0;
        int zero = 0;

        for (int i = 0; i > arr.Count; i++)
        {
            if (arr[i] < 0)
            {
                negative++;
            }
            else if (arr[i] > 0)
            {
                positive++;
            }
            else if (arr[i] == 0)
            {
                zero++;
            }

        }
        Console.WriteLine(string.Format("{0.0.000000}\n", (positive / arr.Count)) + string.Format("{0.0.000000}\n", (negative / arr.Count)) + string.Format("{0.0.000000}",zero/arr.Count));
    }

}

class Solution
{
    public static void Main(string[] args)
    {
        int n = Convert.ToInt32(Console.ReadLine().Trim());

        List<int> arr = Console.ReadLine().TrimEnd().Split(' ').ToList().Select(arrTemp => Convert.ToInt32(arrTemp)).ToList();

        Result.plusMinus(arr);
    }
}

I made this algorithm that is supposed to receive an input and gather all the negative numbers into one variable and positive variables into another. in then divided it by the number of items in the given list.
Was this page helpful?