zoukankan      html  css  js  c++  java
  • 验证用户名和密码,输入三次不正确就锁定账号

    using System;
    using System.Globalization;
    
    class Program
    {
        public static void Main(string[] args)
        {
            var count = 3;
            for (int i = 0; i < count; i++)
            {
                var username = GetString();
                var password = GetString();
                if (username == "zxl" && password == "zxl")
                {
                    Print(username);
                    Print(password);
                    break;
                }
            }
            if (count == 3)
            {
                Print("lock");
            }
        } //Main函数结束
    
    
        #region 工具方法
    
        public static void Print(string obj, params object[] arg)
        {
            Console.WriteLine(obj, arg);
        }
    
        public static void Print(object obj)
        {
            Console.WriteLine(obj);
        }
    
        /// <summary>
        /// 获得一个int类型的值
        /// </summary>
        /// <returns></returns>
        public static int GetInt()
        {
            int i;
            while (true)
            {
                try
                {
                    i = Convert.ToInt32(Console.ReadLine());
                    break;
                }
                catch (FormatException e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            return i;
        }
    
        public static string GetString()
        {
            return Console.ReadLine();
        }
    
        public static double GetDouble()
        {
            double i;
            while (true)
            {
                try
                {
                    i = Convert.ToDouble(Console.ReadLine());
                    break;
                }
                catch (FormatException e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            return i;
        }
    
        #endregion
    }
  • 相关阅读:
    #与javascript:void(0)的区别
    单选框、复选框、下拉列表
    数据类型后的“?”
    c#中日期的处理
    日期控件html
    javascript获取后台传来的json
    Hashtable语法简介
    Hashtable(哈希表)
    Dictionary 字典
    远程SQL Server连接不上
  • 原文地址:https://www.cnblogs.com/zhaoxianglong1987/p/7606574.html
Copyright © 2011-2022 走看看