public class CharuSort (public static void main (String [] args) (int [] sort = (4,6,3,9,5); Sort (sort); for (int i = 0; isort.length ; i + +) System.out.pri ...
public class CharuSort (public static void main (String [] args) (int [] sort = (4,6,3,9,5);
Sort (sort);
for (int i = 0; i
System.out.print (sort [i] + "");
)
public static void Sort (int [] sort) (
int i; / / to scan times
int j; / / get elements as compared
for (i = 1; i
int temp; / / temp used for temporary data
temp = sort [i];
j = i-1;
while (j> = 0 & & temp
sort [j +1] = sort [j]; / / put all the elements of a position pushed back
j -;
)
sort [j +1] = temp; / / smallest element into the first position
)
)
)
No comments:
Post a Comment