Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Array1_4
- {
- //MAIN METHODE
- public static void main (String[] args)
- {
- // sortieren von integer werten
- int [] Array = {4, 2, 56, 7, 87, 89, 23};
- int [] y = ArrangeInt(Array);
- //schleife zum ausgeben
- for(int stelle=0, ende=y.length; stelle<ende; stelle++)
- {
- if(stelle==0)
- {
- System.out.print("|");
- }
- System.out.print(" "+(y[stelle])+" |");
- }
- }
- //Methode zum ordnen:
- static int[] ArrangeInt (int[] ordnen)
- {
- boolean vertauscht = true;
- while (vertauscht)
- {
- vertauscht = false;
- for(int Stelle = 0; Stelle<ordnen.length-1; Stelle++)
- {
- if(ordnen[Stelle]>ordnen[Stelle+1])
- {
- TauschenInt(ordnen,Stelle,Stelle+1);
- vertauscht = true;
- }
- }
- }
- return ordnen;
- }
- //Methode zum tauschen:
- static int[] TauschenInt(int[] d, int e, int f)
- {
- int zwispei = d[e];
- d[e] = d[f];
- d[f] = zwispei;
- return d;
- }
- }
Add Comment
Please, Sign In to add comment