题解 | 神秘石像的镜像序列

神秘石像的镜像序列

https://www.nowcoder.com/practice/fa34eea974234610b6d3d81790cb2949

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = 0;
        int[] arr = new int[101];
        while(true){
            int n = sc.nextInt();
            if(n == 0){
                break;
            }
            arr[count] = n;
            count ++;
        }
        for(int i = 0,j=count-1; i < j;i++,j--){
            int temp = arr[i];
            arr[i] = arr[j];
            arr[j] = temp;
        }
        for(int i = 0;i < count;i++){
            System.out.print(arr[i] + " ");
        }
    }
}

全部评论

相关推荐

不知道怎么取名字_:愚人节收到的吧,刚看到有人也是愚人节说收到offer的
腾讯求职进展汇总
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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