使用经典的三个反转旋转数组
//package com.nowjava; public class Main {/*来自 n o w j a v a . c o m*/ /** * Rotates array using classic three reversals * @param list * @param k */ public static void rotateArrayReversal(Character[] list, int k) { int n = k % list.length; reverseArrayFromToPosition(list, 0, list.length - 1); reverseArrayFromToPosition(list, 0, n - 1); reverseArrayFromToPosition(list, n, list.length - 1); } public static void reverseArrayFromToPosition(Character[] list, int fromPos, int toPos) { //System.out.println("from Pos: " + fromPos + " to Pos" + toPos); int numIterations = (int) Math.ceil((toPos - fromPos) / 2.0); for (int x = fromPos; x < fromPos +