Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class aahilfe
- {
- public static void main(String[] args)
- {
- System.out.println("Wie viele Werte möchten sie eingeben?");
- Scanner eingabe = new Scanner (System.in);
- int anzahlDerWerte = eingabe.nextInt();
- System.out.println("Geben Sie nun den Wert / die Werte ein:");
- double[] unsort = new double[anzahlDerWerte];
- for (int i = 0; i < anzahlDerWerte; i++)
- {
- unsort[i] = eingabe.nextDouble();
- }
- sortArray(unsort);
- }
- static void sortArray (double[] unsort)
- {
- double[] sort = unsort.clone();
- double zwischenspeicher = 0.0;
- for (int i = 0; i < sort.length; i++)
- {
- for (int a = i+1; a < sort.length ; a++)
- {
- if (sort[i] > sort[a])
- {
- zwischenspeicher = sort[i];
- sort[i] = sort[a];
- sort[a] = zwischenspeicher;
- }
- }
- System.out.println(sort[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement