34
1
using System;
2
3
public class Program
4
{
5
public static void Main()
6
{
7
int[] arr={6,5,3,1,8,7,2,4};
8
Console.Write("Arry To Sort: ");
9
for (int i = 0; i < arr.Length; i++)
10
{if(i!=0)Console.Write(",");
11
Console.Write(arr[i]);
12
}
13
for (int i = arr.Length - 1; i > 0; i--)
14
{
15
for (int j = 0; j <= i - 1; j++)
16
{
17
if (arr[j] > arr[j + 1])
18
19
{
20
int big = arr[j];
21
arr[j] = arr[j + 1];
22
arr[j + 1] = big;
23
}
24
}
25
}
26
Console.WriteLine("");
27
Console.Write("Sorted Array: ");
28
for (int i = 0; i < arr.Length; i++)
29
{
30
if(i!=0)Console.Write(",");
31
Console.Write(arr[i]);
32
}
33
}
34
}
Cached Result