Objective-C :: Aufgabe #32

1 Lösung Lösung öffentlich

99 Bottles of Beer - Selbstständige Lösung

Anfänger - Objective-C von pocki - 11.01.2013 um 14:07 Uhr
Programmiere eine eigenständige Lösung zur gängigen Programmier-Übung bzw. Lied 99 Bottles of Beer

Ausgabe:

Konsolenausgabe:


99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 99 bottles of beer on the wall.

98 bottles of beer on the wall, 98 bottles of beer.
... usw.

Lösungen:

vote_ok
von igor_igor (180 Punkte) - 11.12.2013 um 08:36 Uhr
Quellcode ausblenden C-Code
#include <stdio.h>
void singTheSong(int numberOfBottles)
{
    if (numberOfBottles == 0) {
        printf("There are simply no more bottles of beer on the wall.\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);
        singTheSong(oneFewer); // This function calls itself!
        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; }

2109086

Du scheinst einen AdBlocker zu nutzen. Ich würde mich freuen, wenn du ihn auf dieser Seite deaktivierst und dich davon überzeugst, dass die Werbung hier nicht störend ist.