Guest User

Untitled

a guest
Dec 11th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. package PracticeJJava.PracticeJavaQuest2;
  2.  
  3. import java.util.Arrays;
  4.  
  5. public class SelectionSort {
  6. public static void main(String[] args) {
  7. int[] a={6,4,3,1,10,2,5};
  8. int i,minIndex,j,temp,count=0;
  9.  
  10. for (i=0;i<a.length;i++){
  11. minIndex=i;
  12. for(j=i+1;j<a.length;j++){
  13. if(a[j]<a[minIndex]){
  14. temp=a[j];
  15. a[j]=a[minIndex];
  16. a[minIndex]=temp;
  17. // System.out.println("I am the value of a[0] " +a[minIndex]);
  18. //System.out.println(minIndex+ "This is count "+count++);
  19. }
  20. }
  21.  
  22. }System.out.println(Arrays.toString(a));
  23.  
  24. }
  25. }
Add Comment
Please, Sign In to add comment