Algorithm/이론
[자료구조] Bubble Sort (버블 소트)
SweetDev
2021. 8. 4. 17:16

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
int[] b = new int[] { 99,8,4,6,9 };
int temp = 0;
for (int i = 1; i < b.Length; i++)
{
for (int j = i + 1; j < b.Length; j++)
{
if (b[i] > b[j])
{
temp = b[i];
b[i] = b[j];
b[j] = temp;
}
}
}
for (int i = 0; i < b.Length; i++)
{
Console.Write(b[i] + ", ");
}
}
}
}