import java.util.Scanner; public class Demo02{ publicstatic void main(String[] args) { Scannersc = new Scanner(System.in); int a,b, c; System.out.println("请输入三个数"); a =sc.nextInt(); b =sc.nextInt(); c =sc.nextInt(); inte;//用于两个数交换的中间数 //求出a,b中最小的数 if (a> b) { e= a; a= b; b= e; } //求出a,c中最小的数 if (a> c) { e= a; a= c; c= e; } //求出b,c中最小的数 if (b> c) { e= b; b= c; c= e; } System.out.println("三个数由小到大为:" + a + " " + b + " " + c); } }
|