14,编写一个应用程序用来输入的字符串加密,对于字符串的加密规则如下:‘a’->‘d’ ‘b’->‘e’ ‘w’->‘z’…‘x’->‘a’ ‘y’->‘b’ ‘z’->‘c’ ‘A’->‘D’ ‘B’->’'E ‘W’->‘Z’…‘X’->‘A’ ‘y’->‘B’ ‘Z’->‘C’,对其他字符,不进行加密
int letter;
string str = Console.ReadLine();
for (int i = 0; i < str.Length; i++)
{
if (str[i] >= 'a' && str[i] <= 'z')
{
letter = (int)str[i] + 3;
if (letter > 'z')
letter -= 26;//letter已经加3了,z是122,加3后125,而c是99,所以减26
Console.Write((char)letter);
}
else if (str[i] >= 'A' && str[i] <= 'Z')
{
letter = (int)str[i] + 3;
if (letter > 'Z')
letter -= 26;//letter已经加3了,z是122,加3后125,而c是99,所以减26
Console.Write((char)letter);
}
else
Console .Write(str[i]);
}