标签:pac div main oid javase start log else int start
package cn.itcast.javase; public class Test06 { /** * 对给定数组进行反转 * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int arr[]={8,3,5,2,9,1}; print(arr); inversion(arr); print(arr); } private static void inversion(int[] arr) { // TODO Auto-generated method stub for(int start=0,end=arr.length-1;start<end;start++,end--){ swap(arr,start,end); } } private static void swap(int[] arr, int start, int end) { // TODO Auto-generated method stub int temp; temp=arr[start]; arr[start]=arr[end]; arr[end]=temp; } private static void print(int[] arr) { // TODO Auto-generated method stub System.out.print("["); for (int i = 0; i < arr.length; i++) { if(i!=arr.length-1) System.out.print(arr[i]+","); else System.out.println(arr[i]+"]"); } } }
标签:pac div main oid javase start log else int start
原文地址:http://www.cnblogs.com/TaoLeonis/p/6507202.html