- Registriert
- 27.07.09
- Beiträge
- 52
Also eins vorneweg: dass es ein Sortierverfahren ist, weiß ich ^^
Was bedeuten die eckigen Klammern, wofür steht "array.length", wozu ist das "%"-Zeichen gut, u.v.m.
public void Shell_Sort(int[] array) {
int t = 0;
if (array.length % 2 == 0)
t = array.length >> 1;
else
t = (array.length >> 1) + 1;
while (t >= 1) {
for (int i = t,temp = 0; i < array.length; i++) {
for (int j = i - t; j >= 0; j =j - t) {
if (array[j] > array[j + t]) {
temp = array[j];
array[j] = array[j + t];
array[j + t] = temp;
}
}
}
if (t == 1)
break;
if (t % 2 == 0)
t = t >> 1;
else
t = (t >> 1) + 1;
}
}
Ich bedanke mich im vorraus !
Ps: Hab es ins Café gepackt, weil mir kein anderes Forum sinvoll erschien ^^
Gruß,
iUser
Was bedeuten die eckigen Klammern, wofür steht "array.length", wozu ist das "%"-Zeichen gut, u.v.m.
public void Shell_Sort(int[] array) {
int t = 0;
if (array.length % 2 == 0)
t = array.length >> 1;
else
t = (array.length >> 1) + 1;
while (t >= 1) {
for (int i = t,temp = 0; i < array.length; i++) {
for (int j = i - t; j >= 0; j =j - t) {
if (array[j] > array[j + t]) {
temp = array[j];
array[j] = array[j + t];
array[j + t] = temp;
}
}
}
if (t == 1)
break;
if (t % 2 == 0)
t = t >> 1;
else
t = (t >> 1) + 1;
}
}
Ich bedanke mich im vorraus !

Ps: Hab es ins Café gepackt, weil mir kein anderes Forum sinvoll erschien ^^
Gruß,
iUser