Sorting - Bubble Sort

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AsscendingOrder
{
class Program
{
static void Main(string[] args)
{
int[] a = { 2,1,2,1,2,13,19,31,6};

for (int j = a.Length - 1; j > 0; j--)
{
for (int i = 0; i < j; i++)
{
if (a[i] > a[i + 1])
{
int temp = a[i];
a[i] = a[i + 1];
a[i + 1] = temp;
}
}
}

for (int i = 0; i < a.Length; i++ )
Console.WriteLine(a[i]);
Console.ReadLine();
}
}
}

Comments

Popular posts from this blog

Network Security: LAN manager authentication level

Cisco AnyConnect Secure Mobility Client - VPN service not available. The VPN agent service is not responding