static void Main(string[] args)
{
int[] A = { 12, -5, -9, 3, 6, 19, -13, -22, 33, 1, -17, 29 };
Console.WriteLine("\n==============Unsorted Array Input=====================");
for (int i = 0; i < A.Length; i++)
{
Console.WriteLine(A[i]);
}
//=====================================================================
for (int i = A.Length - 1; i > 0; i--)
{
for (int j = 0; j <= i - 1; j++)
{
if (A[j] > A[j+1])
{
int highValue = A[j];
A[j] = A[j+1];
A[j+1] = highValue;
}
}
}
//=====================================================================
Console.WriteLine("\n==============Sorted Array Input=====================");
for (int i = 0; i < A.Length; i++)
{
Console.WriteLine(A[i]);
}
Console.ReadLine();
}
}
}
No comments:
Post a Comment