35 lines
746 B
Text
35 lines
746 B
Text
class Nth {
|
|
function : OrdinalAbbrev(n : Int ) ~ String {
|
|
ans := "th"; # most of the time it should be "th"
|
|
if(n % 100 / 10 = 1) {
|
|
return ans; # teens are all "th"
|
|
};
|
|
|
|
select(n % 10){
|
|
label 1: { ans := "st"; }
|
|
label 2: { ans := "nd"; }
|
|
label 3: { ans := "rd"; }
|
|
};
|
|
|
|
return ans;
|
|
}
|
|
|
|
function : Main(args : String[]) ~ Nil {
|
|
for(i := 0; i <= 25; i+=1;) {
|
|
abbr := OrdinalAbbrev(i);
|
|
"{$i}{$abbr} "->Print();
|
|
};
|
|
|
|
""->PrintLine();
|
|
for(i := 250; i <= 265; i+=1;) {
|
|
abbr := OrdinalAbbrev(i);
|
|
"{$i}{$abbr} "->Print();
|
|
};
|
|
|
|
""->PrintLine();
|
|
for(i := 1000; i <= 1025; i+=1;) {
|
|
abbr := OrdinalAbbrev(i);
|
|
"{$i}{$abbr} "->Print();
|
|
};
|
|
}
|
|
}
|