Ruby :: Aufgabe #32 :: Lösung #1
1 Lösung

#32
99 Bottles of Beer - Selbstständige Lösung
Anfänger - Ruby
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 Idef1x (1320 Punkte)
- 18.05.2018 um 09:52 Uhr

def bottles99() x = 99 while x >= 1 do if x > 2 then puts "#{x} bottles of beer on the wall,\n#{x} bottles of beer.\nTake one down, pass it around,\n#{x-1} bottles of beer on the wall." elsif x == 2 puts "#{x} bottles of beer on the wall,\n#{x} bottles of beer.\nTake one down, pass it around,\n#{x-1} bottle of beer on the wall." elsif x == 1 puts "One last bottle of beer on the wall,\nOne last bottle of beer.\nTake it down, pass it around,\nNo more bottles of beer on the wall." end x -= 1 end end bottles99()
Kommentare:
Für diese Lösung gibt es noch keinen Kommentar
Seite 1 von 0
1