import java.util.*;
class selectionsort
{
public static void main(String[] args)
{
int []a = {15,25,2,8,19,22,5,30,0,7} ;
selectionsort(a);
for(int i=0;i<=a.length-1;i++)
System.out.println(a[i]);
}
public static void selectionsort(int[] a)
{
for(int i=0;i<=a.length-2;i++)
{
int pos=i;
for(int j=i+1;j<=a.length-1;j++)
if(a[j]<a[pos])
pos=j;
int t=a[pos];
a[pos]=a[i];
a[i]=t;
}
}
}
class selectionsort
{
public static void main(String[] args)
{
int []a = {15,25,2,8,19,22,5,30,0,7} ;
selectionsort(a);
for(int i=0;i<=a.length-1;i++)
System.out.println(a[i]);
}
public static void selectionsort(int[] a)
{
for(int i=0;i<=a.length-2;i++)
{
int pos=i;
for(int j=i+1;j<=a.length-1;j++)
if(a[j]<a[pos])
pos=j;
int t=a[pos];
a[pos]=a[i];
a[i]=t;
}
}
}
No comments:
Post a Comment
Thank You !