N'th: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (Add Draco) |
|||
Line 1,498: | Line 1,498: | ||
=={{header|Delphi}}== |
=={{header|Delphi}}== |
||
See [https://www.rosettacode.org/wiki/N%27th#Pascal Pascal]. |
See [https://www.rosettacode.org/wiki/N%27th#Pascal Pascal]. |
||
=={{header|Draco}}== |
|||
<lang draco>proc nonrec nth(word n; *char buf) *char: |
|||
channel output text ch; |
|||
open(ch, buf); |
|||
write(ch; n, |
|||
if (n/10)%10=1 then "th" |
|||
elif n%10=1 then "st" |
|||
elif n%10=2 then "nd" |
|||
elif n%10=3 then "rd" |
|||
else "th" |
|||
fi |
|||
); |
|||
close(ch); |
|||
buf |
|||
corp; |
|||
proc nonrec print_range(word start, stop) void: |
|||
[8] char buf; |
|||
word col, n; |
|||
col := 0; |
|||
for n from start upto stop do |
|||
write(nth(n, &buf[0])); |
|||
col := col + 1; |
|||
if col%10=0 then writeln() else write('\t') fi |
|||
od; |
|||
writeln() |
|||
corp |
|||
proc nonrec main() void: |
|||
print_range(0, 25); |
|||
print_range(250, 265); |
|||
print_range(1000, 1025) |
|||
corp</lang> |
|||
{{out}} |
|||
<pre>0th 1st 2nd 3rd 4th 5th 6th 7th 8th 9th |
|||
10th 11th 12th 13th 14th 15th 16th 17th 18th 19th |
|||
20th 21st 22nd 23rd 24th 25th |
|||
250th 251st 252nd 253rd 254th 255th 256th 257th 258th 259th |
|||
260th 261st 262nd 263rd 264th 265th |
|||
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</pre> |
|||
=={{header|Elena}}== |
=={{header|Elena}}== |