void printSucessiveSum(int N)
{
if (N <=2)
return;
int maxNum = 0;
int start = 1;
int end = 2;
int curSum = 3;
if (N & 0x1)
maxNum = N/2+1;
else
maxNum = N/2;
while (end < maxNum)
{
while (curSum < N)
{
curSum += ++end;
}
while (curSum > N)
{
curSum -= start++;
}
printf ("start from %d-%d", start, end);
curSum += ++end;
curSum -= start++;
}
}
和为n连续正数序列
最新推荐文章于 2020-08-01 11:38:13 发布