-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnitTest1.cs
More file actions
49 lines (42 loc) · 1.39 KB
/
Copy pathUnitTest1.cs
File metadata and controls
49 lines (42 loc) · 1.39 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
int[] arrayToSort = [4, 2, 5, 8, 1, 7];
int[] backwards = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0];
Console.WriteLine(Algorithm.printArray(Algorithm.Swap(backwards)));
Console.WriteLine(Algorithm.printArray(Algorithm.Swap(backwards)));
Console.WriteLine(Algorithm.printArray(Algorithm.Swap(backwards)));
Console.WriteLine(Algorithm.printArray(Algorithm.Swap(backwards)));
Console.WriteLine(Algorithm.printArray(Algorithm.Swap(backwards)));
Console.WriteLine(Algorithm.printArray(Algorithm.Swap(backwards)));
public static class Algorithm{
public static int[] Swap(int[] sort){
// int storePosition = sort[swap1];
// for(int i = 0; i < sort.Length; i++){
// storePosition = sort[swap1];
// if(sort[swap1] > i){
// sort[swap1] = i;
// sort[i] = storePosition;
// }
// }
for(int i = 1; i < sort.Length; i++){
int savePosition = sort[i - 1];
if(sort[i] < sort[i - 1]){
sort[i - 1] = sort[i];
sort[i] = savePosition;
}
}
return sort;
}
public static string printArray(int[] arrayToPrint){
string printedArray = "";
foreach(int point in arrayToPrint){
printedArray += point + " ";
}
return printedArray;
}
}
public class UnitTest1
{
[Fact]
public void Test1()
{
}
}