Sunday 23 September 2012

Bubble Sort

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]);
}
}

0 comments:

Post a Comment