Source:-
using System;
class CsharpSchool
{
static void Main()
{
int[] a = { 4, 6, 9, 83, 34, 45 };
int temp;
for (int pass = 1; pass <= a.Length - 2; pass++)
{
for (int i = 0; i <= a.Length - 2; i++)
{
if (a[i] > a[i + 1])
{
temp = a[i + 1];
a[i + 1] = a[i];
a[i] = temp;
}
}
}
Console.WriteLine("The Sorted array");
foreach (int aa in a)
Console.Write(aa + " ");
Console.Read();
}
}
class CsharpSchool
{
static void Main()
{
int[] a = { 4, 6, 9, 83, 34, 45 };
int temp;
for (int pass = 1; pass <= a.Length - 2; pass++)
{
for (int i = 0; i <= a.Length - 2; i++)
{
if (a[i] > a[i + 1])
{
temp = a[i + 1];
a[i + 1] = a[i];
a[i] = temp;
}
}
}
Console.WriteLine("The Sorted array");
foreach (int aa in a)
Console.Write(aa + " ");
Console.Read();
}
}
Output:-
|
The Sorted
array
4 6 9 34 45 83 |