99 Bottles of Mate… Ein Lied mit … Recursion

Heute im Programm die 99-bottles-of-Mate als Song in der Programmier Version in schlichten C ist mir bei der Erklärung der Rekursion (sich selbst aufrufende Funktionen) über den Bildschirm geflackert und ich musste es etwas umdichten und auch mal … Ausprobieren (Compilieren).

Hier der Code:
#include

void singTheSong(int numberOfBottles)
{
if (numberOfBottles == 0) {
printf("There are simpliy no more bottles of Mate on the wall.\n"); // umdichtung in Mate ! :-)
}else {
printf("%d bottles of Mate on the wall. %d bottles of Mate.\n", numberOfBottles, numberOfBottles);
int oneFewer = numberOfBottles -1;
printf("Take one down, pass it around, %d bottles of Mate on the Wall.\n", oneFewer);

singTheSong(oneFewer); // This function calls itself ! ... RECURSION

printf("Put a bottle in the recycling, %d empty bottles in the bin.\n", numberOfBottles);
}
}

int main(int argc, const char * argv[])
{

// insert code here...
printf("Hello, World! now The ... M a t e SONG \n\n\n");

singTheSong(99);

return 0;
}

Konsolen Ausgabe :

Hello, World! now The … M a t e SONG

99 bottles of Mate on the wall. 99 bottles of Mate.
Take one down, pass it around, 98 bottles of Mate on the Wall.
98 bottles of Mate on the wall. 98 bottles of Mate.
Take one down, pass it around, 97 bottles of Mate on the Wall.
97 bottles of Mate on the wall. 97 bottles of Mate.
Take one down, pass it around, 96 bottles of Mate on the Wall.
96 bottles of Mate on the wall. 96 bottles of Mate.
Take one down, pass it around, 95 bottles of Mate on the Wall.

95 bottles of Mate on the wall. 95 bottles of Mate.
Take one down, pass it around, 94 bottles of Mate on the Wall.
94 bottles of Mate on the wall. 94 bottles of Mate.
Take one down, pass it around, 93 bottles of Mate on the Wall.
93 bottles of Mate on the wall. 93 bottles of Mate.
Take one down, pass it around, 92 bottles of Mate on the Wall.
92 bottles of Mate on the wall. 92 bottles of Mate.
Take one down, pass it around, 91 bottles of Mate on the Wall.
91 bottles of Mate on the wall. 91 bottles of Mate.
Take one down, pass it around, 90 bottles of Mate on the Wall.
90 bottles of Mate on the wall. 90 bottles of Mate.
Take one down, pass it around, 89 bottles of Mate on the Wall.
89 bottles of Mate on the wall. 89 bottles of Mate.
Take one down, pass it around, 88 bottles of Mate on the Wall.
88 bottles of Mate on the wall. 88 bottles of Mate.
Take one down, pass it around, 87 bottles of Mate on the Wall.
87 bottles of Mate on the wall. 87 bottles of Mate.
Take one down, pass it around, 86 bottles of Mate on the Wall.
86 bottles of Mate on the wall. 86 bottles of Mate.
Take one down, pass it around, 85 bottles of Mate on the Wall.
85 bottles of Mate on the wall. 85 bottles of Mate.
Take one down, pass it around, 84 bottles of Mate on the Wall.
84 bottles of Mate on the wall. 84 bottles of Mate.
Take one down, pass it around, 83 bottles of Mate on the Wall.
83 bottles of Mate on the wall. 83 bottles of Mate.
Take one down, pass it around, 82 bottles of Mate on the Wall.
82 bottles of Mate on the wall. 82 bottles of Mate.
Take one down, pass it around, 81 bottles of Mate on the Wall.
81 bottles of Mate on the wall. 81 bottles of Mate.
Take one down, pass it around, 80 bottles of Mate on the Wall.
80 bottles of Mate on the wall. 80 bottles of Mate.
Take one down, pass it around, 79 bottles of Mate on the Wall.
79 bottles of Mate on the wall. 79 bottles of Mate.
Take one down, pass it around, 78 bottles of Mate on the Wall.
78 bottles of Mate on the wall. 78 bottles of Mate.
Take one down, pass it around, 77 bottles of Mate on the Wall.
77 bottles of Mate on the wall. 77 bottles of Mate.
Take one down, pass it around, 76 bottles of Mate on the Wall.
76 bottles of Mate on the wall. 76 bottles of Mate.
Take one down, pass it around, 75 bottles of Mate on the Wall.
75 bottles of Mate on the wall. 75 bottles of Mate.
Take one down, pass it around, 74 bottles of Mate on the Wall.
74 bottles of Mate on the wall. 74 bottles of Mate.
Take one down, pass it around, 73 bottles of Mate on the Wall.
73 bottles of Mate on the wall. 73 bottles of Mate.
Take one down, pass it around, 72 bottles of Mate on the Wall.
72 bottles of Mate on the wall. 72 bottles of Mate.
Take one down, pass it around, 71 bottles of Mate on the Wall.
71 bottles of Mate on the wall. 71 bottles of Mate.
Take one down, pass it around, 70 bottles of Mate on the Wall.
70 bottles of Mate on the wall. 70 bottles of Mate.
Take one down, pass it around, 69 bottles of Mate on the Wall.
69 bottles of Mate on the wall. 69 bottles of Mate.
Take one down, pass it around, 68 bottles of Mate on the Wall.
68 bottles of Mate on the wall. 68 bottles of Mate.
Take one down, pass it around, 67 bottles of Mate on the Wall.
67 bottles of Mate on the wall. 67 bottles of Mate.
Take one down, pass it around, 66 bottles of Mate on the Wall.
66 bottles of Mate on the wall. 66 bottles of Mate.
Take one down, pass it around, 65 bottles of Mate on the Wall.
65 bottles of Mate on the wall. 65 bottles of Mate.
Take one down, pass it around, 64 bottles of Mate on the Wall.
64 bottles of Mate on the wall. 64 bottles of Mate.
Take one down, pass it around, 63 bottles of Mate on the Wall.
63 bottles of Mate on the wall. 63 bottles of Mate.
Take one down, pass it around, 62 bottles of Mate on the Wall.
62 bottles of Mate on the wall. 62 bottles of Mate.
Take one down, pass it around, 61 bottles of Mate on the Wall.
61 bottles of Mate on the wall. 61 bottles of Mate.
Take one down, pass it around, 60 bottles of Mate on the Wall.
60 bottles of Mate on the wall. 60 bottles of Mate.
Take one down, pass it around, 59 bottles of Mate on the Wall.
59 bottles of Mate on the wall. 59 bottles of Mate.
Take one down, pass it around, 58 bottles of Mate on the Wall.
58 bottles of Mate on the wall. 58 bottles of Mate.
Take one down, pass it around, 57 bottles of Mate on the Wall.
57 bottles of Mate on the wall. 57 bottles of Mate.
Take one down, pass it around, 56 bottles of Mate on the Wall.
56 bottles of Mate on the wall. 56 bottles of Mate.
Take one down, pass it around, 55 bottles of Mate on the Wall.
55 bottles of Mate on the wall. 55 bottles of Mate.
Take one down, pass it around, 54 bottles of Mate on the Wall.
54 bottles of Mate on the wall. 54 bottles of Mate.
Take one down, pass it around, 53 bottles of Mate on the Wall.
53 bottles of Mate on the wall. 53 bottles of Mate.
Take one down, pass it around, 52 bottles of Mate on the Wall.
52 bottles of Mate on the wall. 52 bottles of Mate.
Take one down, pass it around, 51 bottles of Mate on the Wall.
51 bottles of Mate on the wall. 51 bottles of Mate.
Take one down, pass it around, 50 bottles of Mate on the Wall.
50 bottles of Mate on the wall. 50 bottles of Mate.
Take one down, pass it around, 49 bottles of Mate on the Wall.
49 bottles of Mate on the wall. 49 bottles of Mate.
Take one down, pass it around, 48 bottles of Mate on the Wall.
48 bottles of Mate on the wall. 48 bottles of Mate.
Take one down, pass it around, 47 bottles of Mate on the Wall.
47 bottles of Mate on the wall. 47 bottles of Mate.
Take one down, pass it around, 46 bottles of Mate on the Wall.
46 bottles of Mate on the wall. 46 bottles of Mate.
Take one down, pass it around, 45 bottles of Mate on the Wall.
45 bottles of Mate on the wall. 45 bottles of Mate.
Take one down, pass it around, 44 bottles of Mate on the Wall.
44 bottles of Mate on the wall. 44 bottles of Mate.
Take one down, pass it around, 43 bottles of Mate on the Wall.
43 bottles of Mate on the wall. 43 bottles of Mate.
Take one down, pass it around, 42 bottles of Mate on the Wall.
42 bottles of Mate on the wall. 42 bottles of Mate.
Take one down, pass it around, 41 bottles of Mate on the Wall.
41 bottles of Mate on the wall. 41 bottles of Mate.
Take one down, pass it around, 40 bottles of Mate on the Wall.
40 bottles of Mate on the wall. 40 bottles of Mate.
Take one down, pass it around, 39 bottles of Mate on the Wall.
39 bottles of Mate on the wall. 39 bottles of Mate.
Take one down, pass it around, 38 bottles of Mate on the Wall.
38 bottles of Mate on the wall. 38 bottles of Mate.
Take one down, pass it around, 37 bottles of Mate on the Wall.
37 bottles of Mate on the wall. 37 bottles of Mate.
Take one down, pass it around, 36 bottles of Mate on the Wall.
36 bottles of Mate on the wall. 36 bottles of Mate.
Take one down, pass it around, 35 bottles of Mate on the Wall.
35 bottles of Mate on the wall. 35 bottles of Mate.
Take one down, pass it around, 34 bottles of Mate on the Wall.
34 bottles of Mate on the wall. 34 bottles of Mate.
Take one down, pass it around, 33 bottles of Mate on the Wall.
33 bottles of Mate on the wall. 33 bottles of Mate.
Take one down, pass it around, 32 bottles of Mate on the Wall.
32 bottles of Mate on the wall. 32 bottles of Mate.
Take one down, pass it around, 31 bottles of Mate on the Wall.
31 bottles of Mate on the wall. 31 bottles of Mate.
Take one down, pass it around, 30 bottles of Mate on the Wall.
30 bottles of Mate on the wall. 30 bottles of Mate.
Take one down, pass it around, 29 bottles of Mate on the Wall.
29 bottles of Mate on the wall. 29 bottles of Mate.
Take one down, pass it around, 28 bottles of Mate on the Wall.
28 bottles of Mate on the wall. 28 bottles of Mate.
Take one down, pass it around, 27 bottles of Mate on the Wall.
27 bottles of Mate on the wall. 27 bottles of Mate.
Take one down, pass it around, 26 bottles of Mate on the Wall.
26 bottles of Mate on the wall. 26 bottles of Mate.
Take one down, pass it around, 25 bottles of Mate on the Wall.
25 bottles of Mate on the wall. 25 bottles of Mate.
Take one down, pass it around, 24 bottles of Mate on the Wall.
24 bottles of Mate on the wall. 24 bottles of Mate.
Take one down, pass it around, 23 bottles of Mate on the Wall.
23 bottles of Mate on the wall. 23 bottles of Mate.
Take one down, pass it around, 22 bottles of Mate on the Wall.
22 bottles of Mate on the wall. 22 bottles of Mate.
Take one down, pass it around, 21 bottles of Mate on the Wall.
21 bottles of Mate on the wall. 21 bottles of Mate.
Take one down, pass it around, 20 bottles of Mate on the Wall.
20 bottles of Mate on the wall. 20 bottles of Mate.
Take one down, pass it around, 19 bottles of Mate on the Wall.
19 bottles of Mate on the wall. 19 bottles of Mate.
Take one down, pass it around, 18 bottles of Mate on the Wall.
18 bottles of Mate on the wall. 18 bottles of Mate.
Take one down, pass it around, 17 bottles of Mate on the Wall.
17 bottles of Mate on the wall. 17 bottles of Mate.
Take one down, pass it around, 16 bottles of Mate on the Wall.
16 bottles of Mate on the wall. 16 bottles of Mate.
Take one down, pass it around, 15 bottles of Mate on the Wall.
15 bottles of Mate on the wall. 15 bottles of Mate.
Take one down, pass it around, 14 bottles of Mate on the Wall.
14 bottles of Mate on the wall. 14 bottles of Mate.
Take one down, pass it around, 13 bottles of Mate on the Wall.
13 bottles of Mate on the wall. 13 bottles of Mate.
Take one down, pass it around, 12 bottles of Mate on the Wall.
12 bottles of Mate on the wall. 12 bottles of Mate.
Take one down, pass it around, 11 bottles of Mate on the Wall.
11 bottles of Mate on the wall. 11 bottles of Mate.
Take one down, pass it around, 10 bottles of Mate on the Wall.
10 bottles of Mate on the wall. 10 bottles of Mate.
Take one down, pass it around, 9 bottles of Mate on the Wall.
9 bottles of Mate on the wall. 9 bottles of Mate.
Take one down, pass it around, 8 bottles of Mate on the Wall.
8 bottles of Mate on the wall. 8 bottles of Mate.
Take one down, pass it around, 7 bottles of Mate on the Wall.
7 bottles of Mate on the wall. 7 bottles of Mate.
Take one down, pass it around, 6 bottles of Mate on the Wall.
6 bottles of Mate on the wall. 6 bottles of Mate.
Take one down, pass it around, 5 bottles of Mate on the Wall.
5 bottles of Mate on the wall. 5 bottles of Mate.
Take one down, pass it around, 4 bottles of Mate on the Wall.
4 bottles of Mate on the wall. 4 bottles of Mate.
Take one down, pass it around, 3 bottles of Mate on the Wall.
3 bottles of Mate on the wall. 3 bottles of Mate.
Take one down, pass it around, 2 bottles of Mate on the Wall.
2 bottles of Mate on the wall. 2 bottles of Mate.
Take one down, pass it around, 1 bottles of Mate on the Wall.
1 bottles of Mate on the wall. 1 bottles of Mate.
Take one down, pass it around, 0 bottles of Mate on the Wall.
There are simpliy no more bottles of Mate on the wall.
Put a bottle in the recycling, 1 empty bottles in the bin.
Put a bottle in the recycling, 2 empty bottles in the bin.
Put a bottle in the recycling, 3 empty bottles in the bin.
Put a bottle in the recycling, 4 empty bottles in the bin.
Put a bottle in the recycling, 5 empty bottles in the bin.
Put a bottle in the recycling, 6 empty bottles in the bin.
Put a bottle in the recycling, 7 empty bottles in the bin.
Put a bottle in the recycling, 8 empty bottles in the bin.
Put a bottle in the recycling, 9 empty bottles in the bin.
Put a bottle in the recycling, 10 empty bottles in the bin.
Put a bottle in the recycling, 11 empty bottles in the bin.
Put a bottle in the recycling, 12 empty bottles in the bin.
Put a bottle in the recycling, 13 empty bottles in the bin.
Put a bottle in the recycling, 14 empty bottles in the bin.
Put a bottle in the recycling, 15 empty bottles in the bin.
Put a bottle in the recycling, 16 empty bottles in the bin.
Put a bottle in the recycling, 17 empty bottles in the bin.
Put a bottle in the recycling, 18 empty bottles in the bin.
Put a bottle in the recycling, 19 empty bottles in the bin.
Put a bottle in the recycling, 20 empty bottles in the bin.
Put a bottle in the recycling, 21 empty bottles in the bin.
Put a bottle in the recycling, 22 empty bottles in the bin.
Put a bottle in the recycling, 23 empty bottles in the bin.
Put a bottle in the recycling, 24 empty bottles in the bin.
Put a bottle in the recycling, 25 empty bottles in the bin.
Put a bottle in the recycling, 26 empty bottles in the bin.
Put a bottle in the recycling, 27 empty bottles in the bin.
Put a bottle in the recycling, 28 empty bottles in the bin.
Put a bottle in the recycling, 29 empty bottles in the bin.
Put a bottle in the recycling, 30 empty bottles in the bin.
Put a bottle in the recycling, 31 empty bottles in the bin.
Put a bottle in the recycling, 32 empty bottles in the bin.
Put a bottle in the recycling, 33 empty bottles in the bin.
Put a bottle in the recycling, 34 empty bottles in the bin.
Put a bottle in the recycling, 35 empty bottles in the bin.
Put a bottle in the recycling, 36 empty bottles in the bin.
Put a bottle in the recycling, 37 empty bottles in the bin.
Put a bottle in the recycling, 38 empty bottles in the bin.
Put a bottle in the recycling, 39 empty bottles in the bin.
Put a bottle in the recycling, 40 empty bottles in the bin.
Put a bottle in the recycling, 41 empty bottles in the bin.
Put a bottle in the recycling, 42 empty bottles in the bin.
Put a bottle in the recycling, 43 empty bottles in the bin.
Put a bottle in the recycling, 44 empty bottles in the bin.
Put a bottle in the recycling, 45 empty bottles in the bin.
Put a bottle in the recycling, 46 empty bottles in the bin.
Put a bottle in the recycling, 47 empty bottles in the bin.
Put a bottle in the recycling, 48 empty bottles in the bin.
Put a bottle in the recycling, 49 empty bottles in the bin.
Put a bottle in the recycling, 50 empty bottles in the bin.
Put a bottle in the recycling, 51 empty bottles in the bin.
Put a bottle in the recycling, 52 empty bottles in the bin.
Put a bottle in the recycling, 53 empty bottles in the bin.
Put a bottle in the recycling, 54 empty bottles in the bin.
Put a bottle in the recycling, 55 empty bottles in the bin.
Put a bottle in the recycling, 56 empty bottles in the bin.
Put a bottle in the recycling, 57 empty bottles in the bin.
Put a bottle in the recycling, 58 empty bottles in the bin.
Put a bottle in the recycling, 59 empty bottles in the bin.
Put a bottle in the recycling, 60 empty bottles in the bin.
Put a bottle in the recycling, 61 empty bottles in the bin.
Put a bottle in the recycling, 62 empty bottles in the bin.
Put a bottle in the recycling, 63 empty bottles in the bin.
Put a bottle in the recycling, 64 empty bottles in the bin.
Put a bottle in the recycling, 65 empty bottles in the bin.
Put a bottle in the recycling, 66 empty bottles in the bin.
Put a bottle in the recycling, 67 empty bottles in the bin.
Put a bottle in the recycling, 68 empty bottles in the bin.
Put a bottle in the recycling, 69 empty bottles in the bin.
Put a bottle in the recycling, 70 empty bottles in the bin.
Put a bottle in the recycling, 71 empty bottles in the bin.
Put a bottle in the recycling, 72 empty bottles in the bin.
Put a bottle in the recycling, 73 empty bottles in the bin.
Put a bottle in the recycling, 74 empty bottles in the bin.
Put a bottle in the recycling, 75 empty bottles in the bin.
Put a bottle in the recycling, 76 empty bottles in the bin.
Put a bottle in the recycling, 77 empty bottles in the bin.
Put a bottle in the recycling, 78 empty bottles in the bin.
Put a bottle in the recycling, 79 empty bottles in the bin.
Put a bottle in the recycling, 80 empty bottles in the bin.
Put a bottle in the recycling, 81 empty bottles in the bin.
Put a bottle in the recycling, 82 empty bottles in the bin.
Put a bottle in the recycling, 83 empty bottles in the bin.
Put a bottle in the recycling, 84 empty bottles in the bin.
Put a bottle in the recycling, 85 empty bottles in the bin.
Put a bottle in the recycling, 86 empty bottles in the bin.
Put a bottle in the recycling, 87 empty bottles in the bin.
Put a bottle in the recycling, 88 empty bottles in the bin.
Put a bottle in the recycling, 89 empty bottles in the bin.
Put a bottle in the recycling, 90 empty bottles in the bin.
Put a bottle in the recycling, 91 empty bottles in the bin.
Put a bottle in the recycling, 92 empty bottles in the bin.
Put a bottle in the recycling, 93 empty bottles in the bin.
Put a bottle in the recycling, 94 empty bottles in the bin.
Put a bottle in the recycling, 95 empty bottles in the bin.
Put a bottle in the recycling, 96 empty bottles in the bin.
Put a bottle in the recycling, 97 empty bottles in the bin.
Put a bottle in the recycling, 98 empty bottles in the bin.
Put a bottle in the recycling, 99 empty bottles in the bin.

Hier noch links für die die sich den Artikel ganz angesehen haben
In vielen Programmiersprachen http://99-bottles-of-beer.net/
Das sagt Wikipedia http://de.wikipedia.org/wiki/99_Bottles_of_Beer

lustige Lieder in anlenung:
http://www.youtube.com/watch?v=Ak7kedzR8bg&feature=related
ten green bottles hanging on the wall
Hochgeladen von Jangiankotla am 14.04.2009

http://www.youtube.com/watch?v=vWKKuBblumo&feature=related
99 Bottles of Beer on the Wall Part 1
Hochgeladen von 50Parties am 23.10.2009

http://www.youtube.com/watch?v=lQrOhQhdoQI
99 bottles of beer original acoustic
Hochgeladen von rachaelpachel am 05.01.2008

Dieser Beitrag wurde unter Allgemein abgelegt und mit , , verschlagwortet. Setze ein Lesezeichen auf den Permalink.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

*