Guest User

Untitled

a guest
Jun 20th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1.  
  2. public class Example13 {
  3. public void selectionSort(int[] arr) {
  4. int minIndex;
  5. int t;
  6. for (int i = 0; i < arr.length - 1; i++) {
  7. minIndex = i;
  8. for (int j = i + 1; j < arr.length; j++) {
  9. if (arr[j] < arr[minIndex]) {
  10. minIndex = j;
  11. }
  12. }
  13. t = arr[i];
  14. arr[i] = arr[minIndex];
  15. arr[minIndex] = t;
  16. }
  17. }
  18. }
  19.  
  20. public class Example13_Test {
  21. public static void main(String[] args) {
  22. Example12 ob1 = new Example12();
  23. Example13 ob2 = new Example13();
  24. int[] array = new int[5];
  25. ob1.input(array);
  26. ob1.echo(array);
  27. ob2.selectionSort(array);
  28. ob1.echo(array);
  29. }
  30. }
Add Comment
Please, Sign In to add comment