所以修改了一下,正确的答案是13组,循环控制条件是外层循环i最小,j>=i;nNum>=j;这样子避免重复了
int main(int argc, char** argv)
{
int nCount_Num = 0;
for(int i = 1; i <= 5; i++)
{
for(int j = i; j <= 7 ; j++)
{
for(int nNum = j; nNum < 10 ; nNum++)
{
if(15 == i + j + nNum)
{
printf("第%2d组为:%d,%d,%d\n", nCount_Num+1, i, j, nNum);
nCount_Num++;
}
}
}
}
printf("一共有%d组\n", nCount_Num);
return 0;
}