Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. public class ResvCpAry
  2. {
  3.     /*int型数组翻转类*/
  4.     public static int[] resvAryInt (int [] aryInt)
  5.     {
  6.         int aryIntLen;
  7.         aryIntLen = aryInt.length;
  8.         int[] aryIntResved = new int[aryIntLen];
  9.         for (int i = 0; i < aryIntLen; i++)
  10.             aryIntResved [i] = aryInt [aryIntLen - i - 1];
  11.         return aryIntResved;
  12.     }
  13.    
  14.     /*测试翻转类*/
  15.     public static void main(String args[])
  16.     {
  17.         int[] testAryInt = {0, 1, 2, 3, 4, 5};
  18.         int[] resvAry = resvAryInt(testAryInt);
  19.         int len = testAryInt.length;
  20.         String out1 = "原数组: ";
  21.         String out2 = "翻转数组:";
  22.         for (int i = 0; i < len; i++)
  23.         {
  24.             out1 += testAryInt[i];
  25.             out2 += resvAry [i];
  26.         }
  27.         System.out.println(out1);
  28.         System.out.print(out2);
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement