//--------------دریافت تعداد عنصر آرایه و پر کردن آن
Console.WriteLine("Hi,Please enter the number of array elements:");
int n = Convert.ToInt32(Console.ReadLine());
int[] Array = new int[n];
Console.WriteLine("-----------------------");
for (int z = 0; z < Array.Length; z++)
{
Array[z] = Convert.ToInt32(Console.ReadLine());
}
//-----------------Selection_Sort-----------------
int i, j, max, temp;
for (i = Array.Length-1; i > 0; i--)
{
max = 0;
for (j = 1; j <= i; j++)
{
if (Array[max] < Array[j])
{
max = j;
}
}
temp = Array[i];
Array[i] = Array[max];
Array[max] = temp;
}
for (int l = 0; l < Array.Length; l++)
{
Console.WriteLine(Array[l]);
}
Console.ReadKey();