题解 | #数组倒转#

数组倒转

https://www.nowcoder.com/practice/3a90caee736a45e1ad70b1d4105dec5f

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int[] arr = new int[6];
        Scanner scanner = new Scanner(System.in);
        int len = arr.length;
        for (int i = 0; i < len; i++) {
            arr[i] = scanner.nextInt();
        }
        System.out.println(Arrays.toString(arr));

        //write your code here......
        int arr1[] = new int[len];
        for(int i = 0; i < len;i++){
            arr1[i] = arr[len -i -1];
        }
        arr = arr1;

        System.out.println(Arrays.toString(arr));
    }
}

全部评论

相关推荐

05-30 12:03
山西大学 C++
offer来了我跪着接:不是骗子,等到测评那一步就知道为啥这么高工资了
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务