Java Program :
class descending
{
static void compute(int[] a)
{
int i,j,k;
System.out.print("Original array : ");
array.display(a);
System.out.print("\n\nLength : "+a.length);
for(i=0;i<a.length-1;i++)
{
for(j=0;j<a.length-1;j++)
{
if(a[j]<a[j+1])
{
k=a[j];
a[j]=a[j+1];
a[j+1]=k;
}
}
}
System.out.print("\n\nDescending data : ");
for(i=0;i<a.length;i++)
System.out.print(a[i]+" ");
}
}
class descending
{
static void compute(int[] a)
{
int i,j,k;
System.out.print("Original array : ");
array.display(a);
System.out.print("\n\nLength : "+a.length);
for(i=0;i<a.length-1;i++)
{
for(j=0;j<a.length-1;j++)
{
if(a[j]<a[j+1])
{
k=a[j];
a[j]=a[j+1];
a[j+1]=k;
}
}
}
System.out.print("\n\nDescending data : ");
for(i=0;i<a.length;i++)
System.out.print(a[i]+" ");
}
}
nice...thank u
ReplyDelete