Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
38
Task/Rot-13/C-sharp/rot-13.cs
Normal file
38
Task/Rot-13/C-sharp/rot-13.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
class Program
|
||||
{
|
||||
static char Rot13(char c)
|
||||
{
|
||||
if ('a' <= c && c <= 'm' || 'A' <= c && c <= 'M')
|
||||
{
|
||||
return (char)(c + 13);
|
||||
}
|
||||
if ('n' <= c && c <= 'z' || 'N' <= c && c <= 'Z')
|
||||
{
|
||||
return (char)(c - 13);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
static string Rot13(string s)
|
||||
{
|
||||
return new string(s.Select(Rot13).ToArray());
|
||||
}
|
||||
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
foreach (var file in args.Where(file => File.Exists(file)))
|
||||
{
|
||||
Console.WriteLine(Rot13(File.ReadAllText(file)));
|
||||
}
|
||||
if (!args.Any())
|
||||
{
|
||||
Console.WriteLine(Rot13(Console.In.ReadToEnd()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue