“验证码:xxxx”
“请输入验证码:”
“输入的位数不正确!”
大小写都行
“验证成功!/ 验证失败!”

          string a = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890";
            while (true) {
                Random b = new Random();
                string y = "";
                for (int x = 1; x < 5; x++)
                {

                    int c = b.Next(0, a.Length);
                    string d = a.Substring(c, 1);
                    y += d;

                }
                Console.WriteLine(y);
                string input = Console.ReadLine();
                input = input.ToLower();
                y = y.ToLower();
                if (input == y)
                {

                    Console.WriteLine("验证成功");
                    break;
                }
                else if (input.Length != y.Length)
                {
                    Console.WriteLine("输入的位数不正确,请重新输入:");
                }
                else 
                {
                    Console.WriteLine("验证失败,请重新输入:");
                }
            }            
           Console.Read();

 

posted on 2017-11-02 21:26  我勒个去YCQ  阅读(126)  评论(0编辑  收藏  举报