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;
- namespace ConsoleApplication34
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] Names = { "Shimon", "Ofek", "Daniel", "Amir", "Dan", "Matan","Ariel","Kerbel"}; // Names must all begin with either a big letter or a small letter
- for (int j = 0; j < Names.Length; ++j)
- {
- for (int i = 0; i < Names.Length; ++i)
- {
- if (i + 1 < Names.Length)
- {
- if (Names[i].CompareTo(Names[i + 1]) == 1)
- {
- string temp = Names[i];
- Names[i] = Names[i + 1];
- Names[i + 1] = temp;
- }
- }
- }
- }
- Console.WriteLine("Printing array:");
- for (int i = 0; i < Names.Length; ++i)
- {
- Console.Write(Names[i] + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment