我想不使用Arrays对数字进行排序。我有这个:
Scanner s = new Scanner(System.in);
System.out.print("Input 3 numbers: ");
int a = s.nextInt();
int b = s.nextInt();
int c = s.nextInt();
System.out.print("Increscent: ");
if (a >= b) {
int temp;
temp = a;
a = b;
b = temp;
}
if (c < a)
{
System.out.println(c + " " + a + " " + b);
} else if (c > b)
{
System.out.println(a + " " + b + " " + c);
} else
{
System.out.println(a + " " + c + " " + b);
}
但是,如果我想使用更多数字该怎么办?是否有一些更好的代码,或者我必须一直使用这种方式?
相关分类