-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
32 lines (28 loc) · 925 Bytes
/
Program.cs
File metadata and controls
32 lines (28 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Collections.Generic;
using System.Linq;
namespace HelloGit
{
internal static class Program
{
public static void Main(string[] args)
{
var initialArray = new[] {1, 5, 3, 2, 5, 6};
var sortedArray = new[] {1, 2, 3, 5, 5, 6};
BubbleSort(initialArray);
if (!initialArray.Intersect(sortedArray).Any()) throw new Exception("Sorting doesn't work!");
Console.WriteLine("complete!");
}
private static void BubbleSort(IList<int> array)
{
for (int i = 0; i < array.Count; i++)
for (int j = 0; j < array.Count - i - 1; j++)
if (array[j] > array[j + 1])
{
int t = array[j];
array[j] = array[j + 1];
array[j + 1] = t;
}
}
}
}