示例#1
0
文件: main.c 项目: macgen/Development
int main(int argc, const char * argv[])
{
    singSongFor(4);
    
    return 0;
    
}
示例#2
0
void singSongFor(int numberOfBottles)
{
    if (numberOfBottles == 0) {
        printf("there are simply no more bottles of beer on the wall.\n\n");
    } else {
        printf("%d bottles of beer 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\n", oneFewer);
        singSongFor(oneFewer);
        
        printf("Put a bottle in the recycling, %d empty bottles in the bin.\n", numberOfBottles);
    }
}
示例#3
0
void singSongFor (int numberOfBottles){
    if (numberOfBottles == 0){
        printf("There are simply no more bottles of beer on the wall. \n\n");
    } else {
        printf("%d bottles of beer 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\n", oneFewer);
        
        singSongFor(oneFewer); //RECURSION!
        
        // After recursion executions have no more left, code resumes here at 1, each cycle counting back toward the given int in main for singSongFor();
        printf("Put a bottle in the recycling, %d empty bottles in the bin. \n", numberOfBottles);
    }
}
示例#4
0
文件: main.c 项目: macgen/Development
void singSongFor(int numberOfBottles)
{
    if (numberOfBottles == 0)
    {
        printf("There are simply no more bottles of beer on the wall.\n\n");
    }
    else
    {
        printf ("%d bottles of beer 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);
        
        singSongFor(oneFewer);
        
        //Print the message just before the function ends
        printf("Put a bottle in the recycling, %d empty bottles of in the bin.\n", numberOfBottles);
               
        
    }
}