M
MadMax77
Gast
Hi leutz,
ich brauch mal wieder hilfe. *g*
Folgendes Funktioniert nicht
thx leutz
ich brauch mal wieder hilfe. *g*
Folgendes Funktioniert nicht
Code:
/*
* Created on 17.10.2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package de.hvb.max;
/**
* @author MadMax
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public class QuickSort
{
public static void main(String[] args)
{
int[] werte = { 3, 7, 1, 9, 2, 5, 2,4,8,2,1};
werte = qSort(werte);
for (int i = 0; i < werte.length; i++)
{
System.out.print(werte[i] + " ");
}
}
static int[] qSort(int[] liste)
{
qSort(liste, 0, liste.length - 1);
return liste;
}
static void qSort(int[] liste, int re, int li)
{
if (re < li)
{
int vgleich = liste[li];
int r = re-1;
int l = li;
for (;;)
{
while (liste[--r] < vgleich);
while (l > 1 && liste[--l] > vgleich);
if (l < r)
break;
int nliste = liste[r];
System.out.println(nliste);
liste[r] = liste[l];
liste[l] = nliste;
System.out.println(nliste);
}
liste[li] = liste[r];
System.out.println(liste[li]);
liste[r] = vgleich;
System.out.println(liste[r]);
qSort(liste, re, r - 1);
qSort(liste, r + 1, li);
}
}
}
thx leutz