all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,30 @@
|
|||
bundle Default {
|
||||
class Cocktail {
|
||||
function : Main(args : String[]) ~ Nil {
|
||||
values := [9, 7, 10, 2, 9, 7, 4, 3, 10, 2, 7, 10];
|
||||
CountingSort(values, 2, 10);
|
||||
each(i : values) {
|
||||
values[i]->PrintLine();
|
||||
};
|
||||
}
|
||||
|
||||
function : CountingSort(array : Int[], min : Int, max : Int) ~ Nil {
|
||||
count := Int->New[max - min + 1];
|
||||
each(i : array) {
|
||||
number := array[i];
|
||||
v := count[number - min];
|
||||
count[number - min] := v + 1;
|
||||
};
|
||||
|
||||
z := 0;
|
||||
for(i := min; i <= max; i += 1;) {
|
||||
while(count[i - min] > 0) {
|
||||
array[z] := i;
|
||||
z += 1;
|
||||
v := count[i - min]
|
||||
count[i - min] := v - 1;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue