Skip to content

Instantly share code, notes, and snippets.

@tuankiet65
Last active December 10, 2015 19:48
Show Gist options
  • Save tuankiet65/4483351 to your computer and use it in GitHub Desktop.
Save tuankiet65/4483351 to your computer and use it in GitHub Desktop.
99 bottles of beer program
{This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.}
program ninetyninebottlesofbeer;
uses crt;
var i, i2, tmp: longint;
again: boolean;
begin
clrscr;
again:=true;
writeln('Press anykey to begin :)');
readkey;
clrscr;
while again<>false do begin
for i:=99 downto 2 do begin
i2:=i2+1;
case i2 mod 10 of
1: textcolor(blue);
2: textcolor(green);
3: textcolor(white);
4: textcolor(red);
5: textcolor(yellow);
6: textcolor(white);
7: textcolor(lightblue);
8: textcolor(white);
9: textcolor(green);
0: textcolor(blue);
end;
writeln(i, ' bottles of beer on the wall, ', i, ' bottles of beer.');
writeln('Take one down and pass it around, ', i-1, ' bottles of beer on the wall.');
delay(1000); {Change this number if you want. In miliseconds (ms)}
writeln;
end;
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.');
writeln;
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.');
writeln;
delay(1000); {change so its like the one in line 27}
write('That was fun. Want to go again? (1 for true OR 0 for false): ');
readln(tmp);
if tmp=0 then
again:=false
else begin
again:=true;
clrscr;
end;
end;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment