Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package PracticeJJava.PracticeJavaQuest2;
- import java.util.Arrays;
- public class SelectionSort {
- public static void main(String[] args) {
- int[] a={6,4,3,1,10,2,5};
- int i,minIndex,j,temp,count=0;
- for (i=0;i<a.length;i++){
- minIndex=i;
- for(j=i+1;j<a.length;j++){
- if(a[j]<a[minIndex]){
- temp=a[j];
- a[j]=a[minIndex];
- a[minIndex]=temp;
- // System.out.println("I am the value of a[0] " +a[minIndex]);
- //System.out.println(minIndex+ "This is count "+count++);
- }
- }
- }System.out.println(Arrays.toString(a));
- }
- }
Add Comment
Please, Sign In to add comment