Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ArraySort {
- public static void main(String[] args)
- {
- Scanner scanner = new Scanner(System.in);
- System.out.println("Bitte geben Sie die laenge des Arrays an ");
- int laenge_des_arrays = scanner.nextInt();
- int[] mein_array = new int[laenge_des_arrays];
- for(int i = 0; i < laenge_des_arrays; i++)
- {
- System.out.println("Bitte geben Sie die Werte ein");
- int werte = scanner.nextInt();
- mein_array[i] = werte;
- sortArray(mein_array[i], laenge_des_arrays);
- }
- }
- public static void sortArray(int array_wert, int h)
- {
- int[] array_zwei = new int[h];
- for(int i=0; i < h; i++)
- {
- array_zwei[i]= array_wert;
- }
- int hilfsvariable =0;
- int minimum = 0;
- for(int b =0; b < array_zwei.length;b++)
- {
- minimum = b;
- for(int c= b;c <array_zwei.length; c++ )
- {
- if(array_zwei[c]< array_zwei[minimum])
- {
- minimum = c;
- }
- }
- hilfsvariable = array_zwei[b];
- array_zwei[b] = array_zwei[minimum];
- array_zwei[minimum] = hilfsvariable;
- System.out.print(array_zwei[b]+" ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement