forked from Kanyelings/p2-25-coding-challenges-ds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exo40.cs
33 lines (30 loc) · 734 Bytes
/
exo40.cs
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
33
using System;
class exo40
{
static void Main(string[] args)
{
long[] array = { 8, 6, 9, -5, -7, -6, 12, 15, 10, 1, 20, 4, -3, 2 };
long num = array.LongLength;
bubbleSort(array, num);
for (long c = 0; c < num; c++)
{
Console.WriteLine(array[c]);
}
}
static void bubbleSort(long[] list, long n)
{
long t;
for (long c = 0; c < (n - 1); c++)
{
for (long d = 0; d < n - c - 1; d++)
{
if (list[d] > list[d + 1])
{
t = list[d];
list[d] = list[d + 1];
list[d + 1] = t;
}
}
}
}
}