#include
using namespace std;
int main() {
int a[10] = {1,3,5,7,9,2,4,6,8,10};//原数组
int b[10]; //新数组
int n,m=10;//下标元素
for(n=0;n
b[m-1] = a[n];
}
//输出原数组
for(n=0;n
}
//输出新数组
for(n=0;n
}
return 0;
}
package zhangyw.test;
import java.util.Arrays;
public class Test {
public static void main(String[] args) throws Exception {
int[] values = {1, 3, 5, 7, 9, 2, 4, 6, 8, 10};
int[] orginal = Arrays.copyOf(values, values.length);
for (int i = 0; i < values.length / 2; i++) {
int tailIndex = values.length - i - 1;
int temp = values[i];
values[i] = values[tailIndex];
values[tailIndex] = temp;
}
System.out.println("交换前:");
for (int i = 0; i < orginal.length; i++) {
System.out.print(orginal[i] + " ");
}
System.out.println("\n交换后:");
for (int i = 0; i < values.length; i++) {
System.out.print(values[i] + " ");
}
}
}