可以用强,弱来形容.public class Test { public Test(int num) { boolean isHave = false
可以用强,弱来形容.public class Test { public Test(int num) {
boolean isHave = false;
for (int j = 1; j < num; j++) {
int sum = 0;
String numStr = num + " = ";
String str = "";
int i = j;
while (true) {
if (sum > num) {
break;
}
if (sum == num) {
System.out.println(numStr
+ str.substring(0, str.length() - 1));
isHave = true;
break;
}
str = str + i + "+";
sum = sum + i;
i++;
}
}
if (isHave == false) {
System.out.println("have no");
} } public static void main(String[] args) {
new Test(15);
}
}