Split the Array

Call a method GetNumbersFromConsole that reads a count value of int, and then reads count values from the console into an int array. Separate ‘Big’ and ‘Little’ integers into two separate arrays: Big if the integer is greater than 100; Little otherwise. Then output the values in the Big array on one line and the values in the Little array on the next in the following format: “Big: {numbers}” and “Little: {numbers}”. Separate numbers on each line by a space, but do NOT include space at the end of the lines. For example:

4
101
756
3
255
Big: 101 756 255
Little: 3

using System;

namespace Arrays
{
    class SplitArray
    {
        public static void Main(string[] args)
        {
            int[] myArray = GetNumbersFromConsole();
            int[] bigArray = new int[myArray.Length];
            int[] smallArray = new int[myArray.Length];
            
            Console.Write("Big: ");
            for (int i = 0; i < myArray.Length; i++)
            {
                
                if(myArray[i] > 100)
                {
                    
                    bigArray[i] = myArray[i];
                    Console.Write(bigArray[i]);
                    if (i != myArray.Length - 1)
                    {
                        Console.Write(" ");
                    }

                }
            }
            Console.WriteLine();
            Console.Write("Little: ");
            for(int i = 0; i < myArray.Length; i++)
            {
                if(myArray[i] < 100)
                {
                    
                    smallArray[i] = myArray[i];
                    Console.Write(smallArray[i]);
                    if (i != myArray.Length - 1)
                    {
                        Console.Write(" ");
                    }
                    
                }
            }
            
                       
        }

        static int[] GetNumbersFromConsole()
        {
            int count = int.Parse(Console.ReadLine());
            int[] result = new int[count];

            for(int i = 0; i < count; ++i)
            {
                result[i] = int.Parse(Console.ReadLine());
            }

            return result;
        }
    }
}

I don’t really know how not to output "Big: " if there are no numbers bigger than 100(and vice versa for "Little: "). Could you help me out?

Hi, I’ve checked your code, and I think the problem is in the spaces at the end of the line. Your condition
if (i != myArray.Length - 1)
is not sufficient, and it will put spaces in the end of either Big or Little lines. What you can do, is to print:[space]number, for each new number, with an extra condition to not print the space for the first one. Please don’t bother about the case when there are no big or little numbers, you can assume there is always at least one.