A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© pathnet 中级黑马   /  2015-7-12 16:50  /  495 人查看  /  4 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

import java.util.Scanner;
public class Prog{
        public static void main(String[] args){
                Scanner scan = new Scanner(System.in).useDelimiter("\\D");
                System.out.print("请输入三个数:");
                int x = scan.nextInt();
                int y = scan.nextInt();
                int z = scan.nextInt();
                scan.close();
                System.out.println("排序结果:"+sort(x,y,z));
        }
        //比较两个数的大小
        private static String sort(int x,int y,int z){
                String s = null;
                if(x>y){
                        int t = x;
                        x = y;
                        y = t;
                }
                if(x>z){
                        int t = x;
                        x = z;
                        z = t;
                }
                if(y>z){
                        int t = z;
                        z = y;
                        y = t;
                }
                s = x+" "+y+" "+z;
                return s;
        }
}

4 个回复

倒序浏览
不错不错
回复 使用道具 举报
不错,顶一个
回复 使用道具 举报
写入方式好啊,真好。
回复 使用道具 举报
善于总结, 赞一个。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马