Please help me with the task: Reverse the array

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. Print all values from the array on one line, in reverse order, each separated by a space. For the purposes of this task, you should NOT have a space at the end of the line. For example:
>3
>1
>2
>3
3 2 1
/*NOTE: Do not use Console.Write(“\b”) to delete the last character. It is not supported by the code runner.*/

Here is my code:


namespace Arrays
{
   class ReverseArray
   {
       public static void Main(string[] args)
       {
           int[] myArray = GetNumbersFromConsole();
           int array = myArray[0];
           for(int i = myArray.Length; i > 0; --i){
               Console.Write(i);
               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 solved it as the expected output should be, what I missed?

Hi @Niv_Ziv , welcome to CodeEasy!

I think the problem is that your solution adds a space at the end of the line. In the task description, it states that you should NOT have a space at the end of the line.

Hey Croaton,
I’ve tried to avoid the spacing line but it’s still not working :slight_smile:

Its not much I can help without your latest code = please provide it if you need further assistance :slight_smile:
Make sure you remove only the last space, not all of them.