Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static final int max = 10;
- int[] toSortArray = new int[max];
- for(int i = 0; i < max; i++){
- if (i == 0){
- i++;
- }
- for(int j = 0; j < i; j++){
- if(toSortArray[i] < toSortArray[j]){
- int temp;
- temp = toSortArray[i];
- toSortArray[i] = toSortArray[j];
- toSortArray[j] = temp;
- }
- }
- for (int i = 0; i < max; i++) {
- System.out.print(" | " + toSortArray[i]);
- }
- public static void insertSort(int[] A){
- for(int i = 1; i < A.length; i++){
- int value = A[i];
- int j = i - 1;
- while(j >= 0 && A[j] > value){
- A[j + 1] = A[j];
- j = j - 1;
- }
- A[j + 1] = value;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement