您的位置:首页 > 其它

从屏幕输入 x y z 三个整数,按照由小到大的顺序输出它们

2016-08-17 22:33 549 查看
import java.util.*;
public class Test3{
public static void main(String [] args){
/*
从屏幕输入 x y z 三个整数,按照由小到大的顺序输出它们。
*/
System.out.println("请输入三个数字:");
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
int y = sc.nextInt();
int z = sc.nextInt();
int temp;
if(x > y){
temp = x;
x = y;
y = temp;
}
if(y > z){
temp = z;
z = y;
y = temp;
}
if(x > z){
temp = x;
x = z;
z = temp;
}
System.out.println("输入的数字从小到大的顺序为:"+x+" "+y+" "+z);

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: