JAVA 7.12

  1. import java.util.Scanner;
  2. public class ReverseArray {
  3.     public static void main(String[] args) {
  4.         int i;
  5.         int []iList = new int [10];
  6.         int []iList2 = new int [10];
  7.         Scanner input =  new Scanner(System.in);
  8.         // input array
  9.         for ( i=0 ; i<10 ; i++ )
  10.             iList[i] = input.nextInt();
  11.         iList2 = Reverse(iList,iList.length);
  12.         for ( i=0 ; i<10 ; i++ )
  13.             System.out.print(iList2[i]+" ");
  14.            
  15.            
  16.            
  17.     }
  18.     public static int[] Reverse(int [] array,int L)
  19.     {
  20.     int i,j;
  21.     int []iCopy = new int [10];
  22.     for ( i=0 ,j=L-1 ; j>=0 ; j--,i++ )
  23.         iCopy[i] = array[j];
  24.     return iCopy;  
  25.     }
  26. }

留言

這個網誌中的熱門文章

Codeforces --- string task

Uva 674 ---- coin change

codeforces 271A --- beautiful year