Objective-C :: Aufgabe #32 :: Lösung #1
1 Lösung

#32
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:
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.
#1

von igor_igor (180 Punkte)
- 11.12.2013 um 08:36 Uhr

#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; }
Kommentare:
Für diese Lösung gibt es noch keinen Kommentar
Seite 1 von 0
1