99 Bottles of Beer/Pascal: Difference between revisions
m
Fixed syntax highlighting.
(moving code from main task-page to sub-page / Component Pascal) |
m (Fixed syntax highlighting.) |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 1:
<!--
===Pascal===
-->
{{collection|99 Bottles of Beer}}
Line 6:
__toc__
<span style='font-family: "Linux Libertine",Georgia,Times,serif;font-size:150%;'>[[Component Pascal]]</span><hr>
BlackBox Component Builder
<
MODULE BottlesOfBeer;
IMPORT StdLog;
Line 35 ⟶ 32:
END Sing;
END BottlesOfBeer.
</syntaxhighlight>
Execute: ^Q BottlesOfBeer.Sing<br/>
Output:
Line 64 ⟶ 61:
<span style='font-family: "Linux Libertine",Georgia,Times,serif;font-size:150%;'>[[Delphi]]</span><hr>
:''See [[#Pascal|Pascal]]''
<lang pascal>procedure BottlesOfBeer;▼
:''Or
<syntaxhighlight lang="delphi">program Hundred_Bottles;
{$APPTYPE CONSOLE}
uses SysUtils;
Var i : Integer ;
// As requested, some fun : examples of Delphi basic techniques. Just to make it a bit complex
procedure WriteABottle( BottleNr : Integer ) ;
begin
end ;
begin
for i := 99 Downto 1 do begin
WriteABottle(i);
Writeln( C_1_Down ) ;
WriteABottle(i-1);
Writeln ;
End ;
end.</syntaxhighlight>
<span style='font-family: "Linux Libertine",Georgia,Times,serif;font-size:150%;'>[[Pascal]]</span><hr>
var
i:
begin
for i := 99 downto 1 do
if i <> 1 then
begin▼
if i = 2 then
WriteLn('Take one down, pass it around');▼
writeln(i - 1, ' bottles of beer on the wall');
end;▼
writeln;
▲ WriteLn(Format('%d bottles of beer on the wall', [i]));
▲ WriteLn(Format('%d bottles of beer', [i]));
else
▲ WriteLn('Take one down, pass it around');
▲ begin
▲ WriteLn(Format('%d bottles of beer on the wall', [Pred(i)]));
writeln('One bottle of beer on the wall');
writeln('One bottle of beer');
writeln('No more bottles of beer on the wall');
end
end.</syntaxhighlight>
|