Bubble Sort

1 comments - Post a comment

class Bubbesort
{
public static void main(String args[])
{
int sum, i,j,temp = 0;
int []a = new int[5];
for(i=0;i< 5;i++)
a[i] = Integer.parseInt(args[i]);

for(i=0;i< 5;i++)
{
for(j=i+1;j< 5;j++)
{
if (a[i] < a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
for(i=0;i< 5;i++)
System.out.println(a[i]);
}
}

 
This Post has 1 Comment Add your own!
Anonymous - March 13, 2012 at 11:02 PM

thank u so much.......
this is really very useful for us!!1

Post a Comment