Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int[] crossSort(int[] arr)
- {
- int odd = 1;
- int temp;
- int oddLen = arr.length;
- if(oddLen%2==1)
- oddLen--;
- while(odd <= arr.length/2)
- {
- temp = arr[odd];
- arr[odd] = arr[oddLen-odd];
- arr[oddLen-odd] = temp;
- odd+=2;
- }
- for(int i=0;i<arr.length-2;i++)
- {
- if(arr[i] > arr[i+1])
- {
- temp = arr[i];
- arr[i] = arr[i+1];
- arr[i+1] = temp;
- }
- }
- return arr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement