标签:新手学习
import java.util.Scanner;/**
Created by Administrator on 2018/4/19 0019.
/
/
*Compare.java
v.1
*/
public class Compare {
public static void main(String[] args){
Scanner input=new Scanner(System.in);
int num1,num2,num3,a,b,c;
System.out.println("请输入a,b,c的值:");
System.out.println("a:"); //先输入三个数字并储存
num1=input.nextInt();
System.out.println("b:");
num2=input.nextInt();
System.out.println("c:");
num3=input.nextInt();
if(num1>=num2){ //数字比较并排序
if(num3>=num1){
c=num3;b=num1;a=num2;
}else if(num3>=num2){
c=num1;b=num3;a=num2;
}else{
c=num1;b=num2;a=num3;
}
} else{
if(num3>=num2){
c=num3;b=num2;a=num1;
}else if(num3>=num1){
c=num2;b=num3;a=num1;
}else{
c=num2;b=num1;a=num3;
}
}
System.out.println("比较后a,b,c从小到大是:a="+a+",b="+b+",c="+c); //输出排序后的数字
}
}
标签:新手学习
原文地址:http://blog.51cto.com/13704315/2105440