public class Bobble {
public static void main(String[] args)
{
int []a=new int [] {7880,65654,24,45,346,8900} ;
bobble(a);
for(int i=0;i<a.length;i++)
{
System.out.println("a["+i+"]="+a[i]);}
// TODO Auto-generated method stub
}
public static void bobble(int [] a)
{
for(int i=0;i<a.length;i++)
{
for(int j=0;j<a.length-1-i;j++)
{
if(a[j]>a[j+1])
{
int temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
System.out.println(a.length);
}
}
|
|