Skip to content

Instantly share code, notes, and snippets.

@alagalia
Last active August 29, 2015 14:20
Show Gist options
  • Save alagalia/bb2b054de09b98e455fd to your computer and use it in GitHub Desktop.
Save alagalia/bb2b054de09b98e455fd to your computer and use it in GitHub Desktop.
02 Sort Array
using System;
using System.Linq;
class Program
{
static void Main()
{
int[] nums = Console.ReadLine().Split().Select(int.Parse).ToArray();
while (true)
{
bool check = false;
for (int i = 0; i < nums.Length - 1; i++)
{
int temp = 0;
if (nums[i] > nums[i + 1])
{
temp = nums[i + 1];
nums[i + 1] = nums[i];
nums[i] = temp;
check = true;
}
}
if (!check)
{
break;
}
}
Console.WriteLine(string.Join(",", nums));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment