输入三个数,从大到小排序:
import java.util.Scanner;
public class Second{
public static void main(String []args)
{
int a,b,c,d;
Scanner sc = new Scanner(System.in);
System.out.println("请输入第一个数");
a =sc.nextInt();
System.out.println("请输入第二个数");
b = sc.nextInt();
System.out.println("请输入第三个数");
c = sc.nextInt();
/*....<span style="color:#000099;">第一种方法</span>....*/
if(a>=b)
{
d=a;a=b;b=d;
}
if(b>=c)
{
d=b;b=c;c=d;
}
if(c>=a)
{
d=c;c=a;a=d;
}
System.out.println(a+">= "+b+">= "+c);
}
}
/*....<span style="color:#000099;">第二种方法</span>....*/
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);
}
}