int num = 9;
int count = 0;
StringBuffer buffer = new StringBuffer();
boolean isHave = false;
for (int i = 1; i < num; i++)
{
count = 0;
buffer = new StringBuffer();
for (int j = i; j < num; j++)
{
buffer.append(j).append(",");
count += j;
if (count == num)
{
System.out.println(num + "," + buffer.toString().substring(0, buffer.lastIndexOf(",")));
isHave = true;
break;
}
else if (count > num)
{
break;
}
}
}
if (!isHave)
{
System.out.println("none");
}
你想问什么