zoukankan      html  css  js  c++  java
  • 数组的倒置

    直接贴代码

     1 package com.cz.test;
     2 
     3 public class ArrayRevese {
     4 
     5     //数组倒置方法
     6     public static int [] getR(int arr[]){
     7         //首先定义一个新数组
     8         int resver[] =new int[arr.length];
     9         //拿出第一个值,把他放在新数组的最后一个位置
    10         for(int i=0;i<arr.length;i++){
    11             resver[arr.length-1-i]=arr[i];
    12         }
    13         
    14         return resver;
    15     }
    16     
    17     
    18     public static void main(String[] args) {
    19         int [] s={1,2,3,4};
    20         int ss[]=getR(s);
    21         for (int i : ss) {
    22             System.out.println(i);
    23         }
    24     }
    25 }
  • 相关阅读:
    2018ddctf wp
    装饰器
    python作用域
    闭包
    迭代器
    ord() expected string of length 1, but int found
    pygm2安装问题
    elf逆向入门
    【POJ
    【POJ
  • 原文地址:https://www.cnblogs.com/javaweb2/p/6241103.html
Copyright © 2011-2022 走看看