我需要幫助編寫此代碼,所以我可以反轉整數數組並返回它?誰能幫忙?麻煩創建一個方法,需要作爲輸入一個整數數組並返回反向數組
public class Quesitons {
public static void main(String[] args) {
int[] numbers = {1, 2, 3, 4, 5, 6, 8};
int[] a = reverseArray(numbers);
System.out.println(a);
}
public static int[] reverseArray(int[] numbers) {
int [] newArray= new int [numbers.length];
int temp;
int left = numbers[0];
int right = numbers.length;
int mid = left+right/2;
for (int i=0; i<mid;i++){
temp = left;
left= right;
right= temp;
right= right -1;
left= left+1;
left= newArray[0];
right=newArray.length-1;
}
return newArray;
}
}
如果你解釋你正在使用的特定語言,它可能會幫助你獲得幫助。 – furkle 2014-11-04 03:24:09
對不起,它在java – Dee 2014-11-04 03:25:26
什麼是不工作關於你的代碼上面? – furkle 2014-11-04 03:26:54