*/
public static void main(String[] args) throws IOException {
int num = 0;
System.out.println("请输入一个整数");
BufferedReader buf = new BufferedReader(
new InputStreamReader(System.in));
String regex = "\\d+";
String s;
while ((s = buf.readLine()) != null) {
if (s.matches(regex) == false) {
System.out.println("请重新输入一个整数");
continue;
} else {
num = Integer.parseInt(s);
break;
}
}
System.out.print(num + "=");
Fenjie(num);
}
public static void Fenjie(int num) {
for (int i = 2; i < num ; i++) {
while (num % i == 0) {
System.out.print(i + "*");
Fenjie(num / i);
}
}
System.out.print(num);
}
}
|
|