阿旭_
package com.abc.ccc;
import java.util.Arrays;
public class Test {
public static void main(String[] args) {
String[] table = new String[] { "A", "B", "C","*", "1", "2", "3" };
System.out.println("逆序前:" + Arrays.toString(table));
reversedOrder(table);// 开始逆序
System.out.println("逆序后:" + Arrays.toString(table));
}
/**
* 编写一个函数,要求把顺序表A中的数据元素序列逆置后存储到顺序表B中
*
* @param table
* 要逆序的表
*/
public static void reversedOrder(String[] table) {
for (int i = 0; i < table.length / 2; i++) {
String t = table[i];
table[i] = table[table.length - 1 - i];
table[table.length - 1 - i] = t;
}
}
}