Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
32
Task/Nth/C-sharp/nth-1.cs
Normal file
32
Task/Nth/C-sharp/nth-1.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
class Program
|
||||
{
|
||||
private static string Ordinalize(int i)
|
||||
{
|
||||
i = Math.Abs(i);
|
||||
|
||||
if (new[] {11, 12, 13}.Contains(i%100))
|
||||
return i + "th";
|
||||
|
||||
switch (i%10)
|
||||
{
|
||||
case 1:
|
||||
return i + "st";
|
||||
case 2:
|
||||
return i + "nd";
|
||||
case 3:
|
||||
return i + "rd";
|
||||
default:
|
||||
return i + "th";
|
||||
}
|
||||
}
|
||||
|
||||
static void Main()
|
||||
{
|
||||
Console.WriteLine(string.Join(" ", Enumerable.Range(0, 26).Select(Ordinalize)));
|
||||
Console.WriteLine(string.Join(" ", Enumerable.Range(250, 16).Select(Ordinalize)));
|
||||
Console.WriteLine(string.Join(" ", Enumerable.Range(1000, 26).Select(Ordinalize)));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue