Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ReverseArrayInPlace
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- ReverseArray(array);
- Console.WriteLine(string.Join(" ", array));
- }
- static void ReverseArray(int[] array)
- {
- int left = 0;
- int right = array.Length - 1;
- while (left < right)
- {
- int temp = array[left];
- array[left] = array[right];
- array[right] = temp;
- left++;
- right--;
- }
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment