package bookTest3;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class FivePointFourteen {
public static void main(String[] args) {
/*
编写程序,提示用户从键盘输入一个正整数,然后以降序的顺序输出该数的最小因子,例如如果输入的数是120
应该显示的是5 , 3 , 2 , 2,2
// Arrays.sort(array, Collections.reverseOrder());
*/
String str = " ";
System.out.println("请输入一个整数");
Scanner scanner = new Scanner(System.in);
int number1 = 0;//计数输出多少个值
int number = scanner.nextInt();
for (int i = 2; i <= number; ) {
if (number % i == 0) {
number = number / i;
str += "," + i;
} else {
i++;
}
}
// System.out.println(str);
str = str.replaceFirst(",", "");
String[] array = str.split(",");
String[] a = new String[array.length];
int p =0;
for (int i = array.length-1; i>=0 ; i--) {
a[p++] = array[i];
}
System.out.println(Arrays.toString(a));
}
}
2.结果图