Advertisement
Marc1111111111

Untitled

Feb 25th, 2021
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. public class SelectionSort
  2. {
  3. // Instanzvariablen - ersetzen Sie das folgende Beispiel mit Ihren Variablen
  4. int [] A = new int[] {8,15,3,12,9,7};
  5. int n = A.length;
  6. int links, min, i;
  7. /**
  8. * Konstruktor für Objekte der Klasse SelectionSort
  9. */
  10. public SelectionSort()
  11. {
  12. // Instanzvariable initialisieren
  13.  
  14. while (links < n)
  15. {
  16. min = links;
  17. for(int i = links + 1 ;i < A.length; i++)
  18. {
  19. if( A[i] < A[min])
  20. {
  21. min = i;
  22. }
  23. }
  24. int Hilfe = A[i];
  25. A[i] = A[min];
  26. A[min]= Hilfe;
  27. links = links + 1;
  28. }
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement