Guest User

Untitled

a guest
Mar 17th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. public class Array1_4
  2. {
  3. //MAIN METHODE
  4. public static void main (String[] args)
  5. {
  6. // sortieren von integer werten
  7. int [] Array = {4, 2, 56, 7, 87, 89, 23};
  8. int [] y = ArrangeInt(Array);
  9.  
  10. //schleife zum ausgeben
  11. for(int stelle=0, ende=y.length; stelle<ende; stelle++)
  12. {
  13.  
  14. if(stelle==0)
  15. {
  16. System.out.print("|");
  17. }
  18.  
  19. System.out.print(" "+(y[stelle])+" |");
  20. }
  21. }
  22.  
  23. //Methode zum ordnen:
  24. static int[] ArrangeInt (int[] ordnen)
  25. {
  26. boolean vertauscht = true;
  27. while (vertauscht)
  28. {
  29. vertauscht = false;
  30. for(int Stelle = 0; Stelle<ordnen.length-1; Stelle++)
  31. {
  32. if(ordnen[Stelle]>ordnen[Stelle+1])
  33. {
  34. TauschenInt(ordnen,Stelle,Stelle+1);
  35. vertauscht = true;
  36. }
  37. }
  38. }
  39. return ordnen;
  40. }
  41. //Methode zum tauschen:
  42. static int[] TauschenInt(int[] d, int e, int f)
  43. {
  44. int zwispei = d[e];
  45. d[e] = d[f];
  46. d[f] = zwispei;
  47. return d;
  48. }
  49. }
Add Comment
Please, Sign In to add comment