daily pastebin goal
45%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package uebung4;
  2.  
  3. import java.util.Arrays;
  4.  
  5. public class Sortieren {
  6.  
  7.     public static int[] bubblesort(int[] zusortieren) {
  8.         int temp;
  9.         for (int i = 1; i < zusortieren.length; i++) {
  10.             for (int j = 0; j < zusortieren.length - i; j++) {
  11.                 if (zusortieren[j] > zusortieren[j + 1]) {
  12.                     temp = zusortieren[j];
  13.                     zusortieren[j] = zusortieren[j + 1];
  14.                     zusortieren[j + 1] = temp;
  15.                 }
  16.             }
  17.         }
  18.         return zusortieren;
  19.     }
  20.  
  21.     public static void main(String[] args) {
  22.         int[] a = { 2000, 2, 45, 34, 100000, 345, 56, 78, 99, 756, 999, 0, 666, 2345, 7492, 22 };
  23.         System.out.println("Data items in original order");
  24.         System.out.print(Arrays.toString(a));
  25.         System.out.println();
  26.         System.out.println("Data items in ascending order");
  27.         int[] a_sortiert = bubblesort(a);
  28.         System.out.print(Arrays.toString(a_sortiert));
  29.     }
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top