Advertisement
haquaa

Untitled

May 26th, 2016
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _2015_C_sharp_Exam
  8. {
  9.     class Program
  10.     {
  11.         /*
  12.              babadel kol element bel moqabel leeh
  13.              ya3ny law 3andy 1 2 3 4 5 , habadel 1 we 5
  14.              ba3deen 2 we 4
  15.         */
  16.         static int[] ReverseArray(int[] arr) //Method that returns an array.
  17.         {
  18.             int size = arr.Length;
  19.             for (int i = 0; i < size / 2; i++)
  20.             {
  21.                 int temp = arr[i];
  22.                 arr[i] = arr[size - 1 - i];
  23.                 arr[size - 1 - i] = temp;
  24.             }
  25.             return arr;
  26.         }
  27.  
  28.         static void Main(string[] args)
  29.         {
  30.             //Question 2 - b
  31.  
  32.             int[] arr = { 1, 2, 3, 4, 5 };
  33.  
  34.             arr = ReverseArray(arr);
  35.  
  36.             for (int i = 0; i < arr.Length; i++)
  37.             {
  38.                 Console.Write(arr[i] + " ");
  39.             }
  40.  
  41.             Console.WriteLine();
  42.  
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement