逻辑高手请进:求do...while的通用算法
有如下代码片段:if (n == 2)
{
for (int i = 0; i < m - n + 1; i++)
{
for (int j = i + 1; j < m - n + 2; j++)
{
juzhen[counter, 0] = i + 1;
juzhen[counter, 1] = j + 1;
counter++;
}
}
}
if (n == 3)
{
for (int i = 0; i < m - n + 1; i++)
{
for (int j = i + 1; j < m - n + 2; j++)
{
for (int k = j + 1; k < m - n + 3; k++)
{
juzhen[counter, 0] = i + 1;
juzhen[counter, 1] = j + 1;
juzhen[counter, 2] = k + 1;
counter++;
}
}
}
}
......
其中n是任意正整数,大家发现for语句和循环体内的语句会随着n的增加而增加,现在求用do...while替换for循环的通用算法,以适应n不断变化的情况,小弟想了很多天,也没想出来,麻烦各位高手帮想一下.