开发者社区 问答 正文

输入三个整数 x,y,z,请把这三个数由小到大输出

输入三个整数 x,y,z,请把这三个数由小到大输出

展开
收起
珍宝珠 2020-02-13 18:11:35 2353 分享
分享
版权
举报
1 条回答
写回答
取消 提交回答
  • package cskaoyan;
     
    public class cskaoyan15 {
        private static int x;
        private static int y;
        private static int z;
     
        @org.junit.Test
        public void sort() {
            java.util.Scanner in = new java.util.Scanner(System.in);
            x = in.nextInt();
            y = in.nextInt();
            z = in.nextInt();
     
            if (x > y) {
                int temp = x;
                x = y;
                y = temp;
            }
     
            if (x > z) {
                int temp = x;
                x = z;
                z = temp;
            }
     
            if (y > z) {
                int temp = y;
                y = z;
                z = temp;
            }
     
            System.out.println(x + "<" + y + "<" + z);
     
            in.close();
        }
    }
    
    
    2020-02-13 18:11:52 举报
    赞同 评论

    评论

    全部评论 (0)

    登录后可评论
问答地址:
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等