NMDanny

S5

Feb 3rd, 2013
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication34
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             string[] Names = { "Shimon", "Ofek", "Daniel", "Amir", "Dan", "Matan","Ariel","Kerbel"}; // Names must all begin with either a big letter or a small letter
  13.             for (int j = 0; j < Names.Length; ++j)
  14.             {
  15.                 for (int i = 0; i < Names.Length; ++i)
  16.                 {
  17.                     if (i + 1 < Names.Length)
  18.                     {
  19.                         if (Names[i].CompareTo(Names[i + 1]) == 1)
  20.                         {
  21.                             string temp = Names[i];
  22.                             Names[i] = Names[i + 1];
  23.                             Names[i + 1] = temp;
  24.                         }
  25.                     }
  26.                 }
  27.             }
  28.  
  29.             Console.WriteLine("Printing array:");
  30.             for (int i = 0; i < Names.Length; ++i)
  31.             {
  32.                 Console.Write(Names[i] + " ");
  33.             }
  34.         }
  35.  
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment