Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language Delphi

(Recursive version)

Date:01/12/06
Author:Juan Carlos Molinos
URL:n/a
Comments:2
Info:n/a
Score: (2.97 in 35 votes)
program bot99;

{$APPTYPE CONSOLE}

uses
  SysUtils;

procedure Sing(bot:integer);
begin
 Writeln('');
 case bot of
  0: begin
    Writeln('No more bottles of beer on the wall, no more bottles of beer.');
    Writeln('Go to the store and buy some more, '
      +'99 bottles of beer on the wall.');
   end;
  1: begin
    Writeln('1 bottle of beer on the wall, 1 bottle of beer.');
    Writeln('Take one down and pass it around, '
      +'no more bottles of beer on the wall.');
    Sing(bot-1);
   end;
  else
   begin
    Writeln(inttostr(bot)+' bottles of beer on the wall, '
      +inttostr(bot)+' bottles of beer.');
    Writeln('Take one down and pass it around, '+inttostr(bot-1)
      +' bottle of beer on the wall.');
    Sing(bot-1);
   end;
 end;
end;

begin
  Sing(99);
end.

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
OO version - Delphi 7Luis Carlos F. Dias09/10/059
standard versionAnonymous04/20/054
OO Simple version (not using Interfaces)Luis Carlos F. Dias09/04/050
NonVCL versionPhilipp Winterberg04/20/050
OO version (with interface)Luis Carlos F. Dias09/05/050

Comments

>>  Phil Rogers said on 09/15/06 16:17:17

Phil Rogers For the case of 1 bottle, the code should be
Writeln('Take it down and pass it around, '

and not
Writeln('Take one down and pass it around, '

>>  Homolibere said on 03/14/08 16:51:58

Homolibere TOP GEEK! I Like That Small Source Code.

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: