Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
22
Task/Nth/C-sharp/nth-2.cs
Normal file
22
Task/Nth/C-sharp/nth-2.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
|
||||
static string Ordinalize(int i)
|
||||
{
|
||||
return i + (
|
||||
i % 100 is >= 11 and <= 13 ? "th" :
|
||||
i % 10 == 1 ? "st" :
|
||||
i % 10 == 2 ? "nd" :
|
||||
i % 10 == 3 ? "rd" :
|
||||
"th");
|
||||
}
|
||||
|
||||
static void PrintRange(int begin, int end)
|
||||
{
|
||||
for(var i = begin; i <= end; i++)
|
||||
Console.Write(Ordinalize(i) + (i == end ? "" : " "));
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
PrintRange(0, 25);
|
||||
PrintRange(250, 265);
|
||||
PrintRange(1000, 1025);
|
||||
Loading…
Add table
Add a link
Reference in a new issue