Java经典习题34

/*
题目:输入3个数a,b,c,按大小顺序输出。
*/

import java.util.*;

public class Class34 {

public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("输入三个数字(连续每次输入之后回车确认):");
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if(a < b){
int t = a;
a = b;
b = t;
}
if(a < c){
int t = a;
a = c;
c = t;
}
if(b < c){
int t = b;
b = c;
c = t;
}
System.out.println("输出排序好的三个数字。");
System.out.print(a + " " + b + " " + c);

}

}

猜你喜欢

转载自www.cnblogs.com/zhuozige/p/12358756.html