集册 Java实例教程 将数组从位置反转到位置

将数组从位置反转到位置

欢马劈雪     最近更新时间:2020-01-02 10:19:05

385
将数组从位置反转到位置

/* from 
N o w J a v a . c o m - 时  代  Java*/

//package com.nowjava;


public class Main {

    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 + numIterations; x++) {

            char temp = list[x];

            list[x
展开阅读全文