BUBBLE SORTING || PROGRAM
import java.util.Scanner;
class Bubblee
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter 5 no.");
int a[]=new int[5];
for(int k=0;k<a.length;k++)
a[k]=sc.nextInt();
for(int i=0;i<a.length;i++)
{
for(int j=0;j<a.length-1;j++)
if(a[j]<(a[j+1]))
{
int t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
for (int i=0;i<a.length;i++)
{
System.out.println(a[i]);
}
}
}
0 Comments