Zum Inhalt springen

99 Bottles of Beer: Unterschied zwischen den Versionen

C3o (Diskussion | Beiträge)
K hat 99 Bottles of Beers nach 99 Bottles of Beer verschoben: zomg
Vierlex (Diskussion | Beiträge)
Keine Bearbeitungszusammenfassung
 
(Eine dazwischenliegende Version von einem anderen Benutzer wird nicht angezeigt)
Zeile 31: Zeile 31:
  }
  }


== 99 Bottles in Python ==
= 99 Bottles in Python =
  #!/usr/bin/env python
  #!/usr/bin/env python
  # 99 bottles of beer in Python by Ricardo Garcia. Public Domain code.
  # 99 bottles of beer in Python by Ricardo Garcia. Public Domain code.
Zeile 54: Zeile 54:
   
   
  print "\n".join( verses(x) for x in xrange(99, -1, -1) )
  print "\n".join( verses(x) for x in xrange(99, -1, -1) )
= 99 Bottles in Arduino =
int bottles = 99;
void setup() {
  Serial.begin(9600);
}
void loop () {
  if (bottles > 0) {
    printBottles(bottles);
    Serial.print(" of beer on the wall, ");
    printBottles(bottles);
    Serial.print(" of beeeeer . . . , Take one down, pass it around, ");
    bottles--;
    printBottles(bottles);
    Serial.println(" of beer on the wall. ...");
    if (bottles == 0) {
      Serial.println("Time to buy more beer!");
    }
    delay(1000);
  }
}
void printBottles(int nr) {
  if (nr == 0) Serial.print("No more");
  else Serial.print(nr);
  Serial.print("bottle");
  if (nr != 1) Serial.print("s");
}
[[Kategorie:Howto]]