Created
March 10, 2017 05:14
-
-
Save bhavjot/be5df7adf232c1630893d67ba82f44fa to your computer and use it in GitHub Desktop.
Reverese Array- Hacker Rank
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace HackerRank | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
int n = Convert.ToInt32(Console.ReadLine()); | |
string[] arr_temp = Console.ReadLine().Split(' '); | |
int[] arr = Array.ConvertAll(arr_temp, Int32.Parse); | |
for (int i = 0; i < n / 2; i++) | |
{ | |
int temp = arr[i]; | |
arr[i] = arr[n - i - 1]; | |
arr[n - i - 1] = temp; | |
} | |
string reverseArr = string.Join(" ", arr); | |
Console.Write(reverseArr); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment