/*
* Bubble.java
*
* Created on 15. duben 2004, 8:09
*/
/**
*
* @author TO
*/
public class Bubble {
/** Creates a new instance of Bubble */
public Bubble() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int array[] = new int[30];
System.out.println("Před setříděním: ");
for ( int i = 0; i < array.length ; i++)
{
array[i] = (int) (Math.random() * 30.0);
System.out.println(array[i]);
}
bubble_sort(array);
System.out.println("Po setřídění: ");
for ( int i = 0; i < array.length ; i++)
{
System.out.println(array[i]);
}
}
public static void bubble_sort( int array[])
{
int i = array.length;
while (--i >= 0 )
{
for ( int j = 0; j < i; j++ )
{
if ( array[j] > array[j+1] )
{
int temp = array[j];
array[j] = array[j+1];
array[j+1] = temp;
}
}
}
}
}