class sort
{
public static void main(String args[])
{
int a[ ] ={3,5,4,1,2};
int temp, i , j ;
System.out.println("The Array before Sorting :");
for(i=0;i<a.length;i++)
{
System.out.println(" "+a[i]);
}
for(i=0 ; i < a.length ; i++)
{
for(j=i+1;j< a.length ; j++)
{
if(a[i]>a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
System.out.println("The Array After Sorting :");
for(i = 0;i<a.length ;i++)
{
System.out.println(" "+a[i]);
}
}
}
}
{
public static void main(String args[])
{
int a[ ] ={3,5,4,1,2};
int temp, i , j ;
System.out.println("The Array before Sorting :");
for(i=0;i<a.length;i++)
{
System.out.println(" "+a[i]);
}
for(i=0 ; i < a.length ; i++)
{
for(j=i+1;j< a.length ; j++)
{
if(a[i]>a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
System.out.println("The Array After Sorting :");
for(i = 0;i<a.length ;i++)
{
System.out.println(" "+a[i]);
}
}
}
}
No comments:
Post a Comment