关于c语言成语的疑问0
程序如下:
void singTheSong (int numberOfBottles) {
if (numberOfBottles == 0) {
printf("There are no more bottles left.\n");
} else {
printf("%d bottles of bear on the wall, %d bottles of beer.\n", numberOfBottles,
numberOfBottles);
int oneFewer = numberOfBottles - 1;
printf("Take one down, pass it around, %d bottles of beer on the wall.\n", oneFewer);
singTheSong(oneFewer);
printf("put a bottle in the recycling, %d empty bottles in the bin.\n",numberOfBottles);
}
}
int main(int argc, const char * argv[])
{
singTheSong(99);
return 0;
}
运行结果是:99 bottles of bear on the wall, 99 bottles of beer.
Take one down, pass it around, 98 bottles of beer on the wall.
.................................
1 bottles of bear on the wall, 1 bottles of beer.
Take one down, pass it around, 0 bottles of beer on the wall.
There are no more bottles left
put a bottle in the recycling, 1 empty bottles in the bin
........................
put a bottle in the recycling, 99 empty bottles in the bin
前面的我都明白,就是不明白为什么会出现put a bottle in the recycling, 1 empty bottles in the bin这句话,还一直递增呢?