using System.Diagnostics;
public static void Main()
int n = InputInt("number of elements");
for(int i = 0; i < a.Length; i++)
a[i] = InputInt(string.Format("a[{0}]", i));
while (i != u && a[i] != a[u])
swap(ref a[u], ref a[a.Length - s - 1]);
Console.WriteLine("a contains {0} distincs values", u);
for(int i=0; i < u ; i++)
Console.WriteLine("a[{0}]={1}", i, a[i]);
public static int InputInt(string prompt)
Console.Write("Enter " + prompt + ": ");
return Convert.ToInt32(Console.ReadLine());
public static void swap(ref int a, ref int b)