c#字母加密

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
 * 由SharpDevelop创建。
 * 用户: Administrator
 * 日期: 2018/10/14
 * 时间: 21:07
 *
 * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
 */
using System;
 
namespace clianxi3
{
    class Program
    {
        public static void Main(string[] args)
        {
            string str=Console .ReadLine ();
            string temr1="";
            for (int i = 0; i <str .Length; i++){//便利每一个字符
                if (str [i]>='a'&&str[i]<='z') {
                    int num=str[i];
                    num+=3;
                    char temp=(char)num;
                    temp=(char)(temp-'z'+'a'-1);
                    temr1+=temp;
            }else if (str [i]>='A'&&str[i]<='Z') {
                int num=str[i];
                    num+=3;
                    char temp=(char)num;
                    if (temp>'Z') {
                        temp=(char)(temp-'Z'+'A'-1);
                    }
                    temr1+=temp;
                }else{
                    temr1+=str[i];
                }
                 
            }
            Console.WriteLine(temr1);
             
            // TODO: Implement Functionality Here
             
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
    }
}

 

posted @   逐梦武威  阅读(263)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示