package test01;
import java.util.Scanner;
/*
22、编写Java程序:从键盘输入任意的3个整数,从小到大顺序输出。
*/
public class 排序 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if (a > b) {
int temp = a;
a = b;
b = temp;
}
if (a > c){
int temp = a;
a = c;
c = temp;
}
if (b > c) {
int temp = b;
b = c;
c = temp;
}
System.out.println("由小到大的顺序为:" + a + "\t" + b + "\t" + c );
}
}
编写Java程序:从键盘输入任意的3个整数,从小到大顺序输出。
最新推荐文章于 2024-07-21 12:59:55 发布