标签:
1 import java.util.Scanner; 2 3 public class Solution 4 { 5 public static void main(String[] args) 6 { 7 Scanner input = new Scanner(System.in); 8 System.out.print("Enter the count of numbers: "); 9 int count = input.nextInt(); 10 int[] number = new int[count]; 11 12 for(int i = 0; i < count; i++) 13 number[i] = input.nextInt(); 14 15 input.close(); 16 17 for(int i: number) 18 System.out.print(i + " "); 19 System.out.println(); 20 21 int[] anotherNumber = reverse(number); 22 for(int i = 0; i < anotherNumber.length; i++) 23 System.out.print(anotherNumber[i] + " "); 24 } 25 26 public static int[] reverse(int[] array) 27 { 28 int temp; 29 for(int i = 0; i < array.length / 2; i++) 30 { 31 temp = array[i]; 32 array[i] = array[array.length - 1 - i]; 33 array[array.length - 1 - i] = temp; 34 } 35 return array; 36 } 37 }
标签:
原文地址:http://www.cnblogs.com/wood-python/p/5808415.html