Hello, I’m working on this task:
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
Here is my code:
namespace Arrays
{
class SplitArray
{
public static void Main(string[] args)
{
int[] myArray = GetNumbersFromConsole();
// Write your code here
for(int i = 0; i < myArray.Length; i++)
{
if(myArray[i] > 100)
big[bigIndex++] = myArray[i];
else
little[littleIndex++] = myArray[i];
}
}
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;
}
}
}
Can anyone please help me to solve it?