输入4个数,将这4个数按从小到大输出
学习emmm
public class Sort {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入四个数:");
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int d = sc.nextInt();
if(a>=b) {
int f = 0;
f = b;
b = a;
a = f;
}
if(b>=c) {
int f = 0;
f = c;
c = b;
b = f;
}
if(c>=d) {
int f = 0;
f = d;
d = c;
c = f;
}
System.out.println("从小到大为:"+a+","+b+","+c+","+d);
}
}