Advertisement
Guest User

Untitled

a guest
May 26th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1.  
  2. public class Sortieren {
  3.  
  4. public int[] sortit(int[] array){
  5.  
  6. for (int j=1; j<array.length;j++){
  7. int temp=Integer.MAX_VALUE;
  8. int position=0;
  9. int sicherung;
  10. for (int i = j; i<array.length;i++){
  11. if (array[i]<temp){
  12. temp=array[i];
  13. position = i;
  14. }
  15. }
  16. sicherung=array[j];
  17. array[j] = temp;
  18. array[position]=sicherung;
  19.  
  20. }
  21.  
  22.  
  23. return array;
  24. }
  25.  
  26.  
  27. public static void main(String[] args){
  28. int[] test = {1,65,77,32,98,3,4,90};
  29. Sortieren test2 = new Sortieren();
  30. test2.sortit(test);
  31. String ergebnis = "Das Ergebnis lautet: ";
  32. for (int i = 0; i < test.length; i++) {
  33. ergebnis = ergebnis + test[i] +", ";
  34. }
  35. System.out.println(ergebnis);
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement