N'th: Difference between revisions

855 bytes added ,  8 years ago
{{Header|Pascal}}
No edit summary
({{Header|Pascal}})
Line 1,214:
%3 = ["1000th", "1001st", "1002nd", "1003rd", "1004th", "1005th", "1006th", "1007th", "1008th", "1009th", "1010th", "1011th", "1012th", "1013th", "1014th", "1015th", "1016th", "1017th", "1018th", "1019th", "1020th", "1021st", "1022nd", "1023rd", "1024th", "1025th"]
%4 = ["111th", "1012th"]</pre>
=={{Header|Pascal}}==
nearly copy of [[N'th#Ada|Ada]]
<lang pascal>Program n_th;
 
function Suffix(N: NativeInt):AnsiString;
var
res: AnsiString;
begin
res:= 'th';
case N mod 10 of
1:IF N mod 100 <> 11 then
res:= 'st';
2:IF N mod 100 <> 12 then
res:= 'nd';
3:IF N mod 100 <> 13 then
res:= 'rd';
else
end;
Suffix := res;
end;
 
procedure Print_Images(loLim, HiLim: NativeInt);
var
i : NativeUint;
begin
for I := LoLim to HiLim do
write(i,Suffix(i),' ');
writeln;
end;
 
begin
Print_Images( 0, 25);
Print_Images( 250, 265);
Print_Images(1000, 1025);
end.</lang>
{{Out}} shortened
<pre>
0th 1st 2nd 3rd 4th ... 11th 12th 13th ..20th 21st 22nd 23rd 24th 25th
250th 251st 252nd 253rd 254th ..261st 262nd 263rd 264th 265th
..1001st 1002nd 1003rd 1004th..1011th..1013th..1021st 1022nd 1023rd 1024th
</pre>
=={{Header|Perl}}==
{{Trans|Perl 6}}
Anonymous user