Гм... Ну лови, болезный:
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine(Caesar.Crypt(Console.ReadLine(), int.Parse(Console.ReadLine())));
}
}
static class Caesar
{
private static string Alphabet;
private static void BuildAlphabet()
{
Alphabet = string.Empty;
for (char c = 'A'; c <= 'Z'; c++)
Alphabet += c.ToString();
}
static Caesar()
{
BuildAlphabet();
}
public static string Crypt(string _CryptoString, int _Shift)
{
string Result = string.Empty;
var Chars = _CryptoString.ToUpper().ToCharArray();
int PositiveShift = Math.Abs(_Shift) / Alphabet.Length + 2;
foreach (char c in Chars)
{
char CryptoChar = c;
int Pos = Alphabet.IndexOf(CryptoChar);
if (Pos >= 0)
CryptoChar = Alphabet[(Pos + _Shift + PositiveShift * Alphabet.Length) % Alphabet.Length];
Result += CryptoChar;
}
return Result;
}
}