1、
import java.util.Scanner;
public class Covert1 {
public static void main(String[] args){
int a,b,c,t;
Scanner sc=new Scanner(System.in);
//输入
System.out.println("please input the first integer");
a=sc.nextInt();
//获取输入的数
System.out.println("please input the second integer");
b=sc.nextInt();
System.out.println("please input the third integer");
c=sc.nextInt();
-----------------------------------------------------------------
第一种方法:
if(a<b)
{
if(b<c)System.out.println(a+" "+b+" "+c);
else{
if(a<c)System.out.println(a+" "+c+" "+b);
else System.out.println(c+" "+a+" "+b);
}
}
else
{
if(a<c)System.out.println(b+" "+a+" "+c);
else
{
if(b<c)System.out.println(b+" "+c+" "+a);
else System.out.println(c+" "+b+" "+a);
}
}
---------------------------------------------------------------------------
第二种方法:
if(a>b){
t=a;a=b;b=t;
}
if(b>c){
t=b;b=c;c=t;
}
if(a>c){
t=a;a=c;c=t;
}
System.out.println(a+" "+b+" "+c);
---------------------------------------------------------------------------
}
}