(while)要求用戶輸入帳號、密碼,只要不是admin和888就一直提示要求重新輸入

using System;
using System.Collections.Generic;
using System.Text;

namespace while判斷用戶名密碼
{
    class Program
    {
        static void Main(string[] args)
        {
          bool count = true;
            while (count)
            {
                Console.WriteLine("請輸入帳號");
                string username = Console.ReadLine();
                Console.WriteLine("請輸入密碼");
                string password = Console.ReadLine();
                if (username == "admin" && password == "888")
                {
                    count = false;
                }
                else
                {
                    count = true;
                }
            }
            Console.WriteLine("歡迎使用本系統");


            Console.ReadKey();
        }
    }
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章