string mima = ""; string name = "";
bool xuanzhe = true;
while (xuanzhe)
{
Console.WriteLine("****欢迎登入奖客富翁系统*******\n\t1.注册\n\t2.登入\n\t3.抽奖\n*******************************");
Console.Write("请选择菜单:");
int choose = Convert.ToInt32(Console.ReadLine());
switch (choose)
{
case 1:
Console.WriteLine("[奖客富翁系统>注册]");
Console.WriteLine("请注册个人信息");
Console.Write("用户名:");
name = Console.ReadLine();
Console.Write("密码:");
mima = Console.ReadLine();
Random huiyuan = new Random();
Console.WriteLine("注册成功,请记好您的会员卡号\n用户名\t密码\t会员卡号\n{0}\t{1}\t{2}",name ,mima, huiyuan.Next(1000,99999));
break;
case 2:
Console.WriteLine("[奖客富翁系统>登入]");
string sr_mima = ""; string sr_name = "";
bool judge = false;int n=1;
while (!judge )
{
Console.Write("请输入用户名:");
sr_name = Console.ReadLine();
Console.Write("请输入密码:");
sr_mima = Console.ReadLine();
if (sr_name != name || sr_mima != mima)
{
Console.WriteLine("输入有误,请重新输入"); n++;
if (n > 3)
{
Console.WriteLine("您输入错误次数超过3次,系统退出"); return;
}
}
else { Console.WriteLine("欢迎您:{0}", name); judge = true; }
}
break;
default:
string sr_huiyuan = "";
Console.WriteLine("[奖客富翁系统>抽奖]");
Console.Write("请输入会员卡号:");
sr_huiyuan = Console.ReadLine();
Random zj_huiyuan = new Random();
int[] lucknum = new int[5];
for (int i = 0; i < 5; i++)
{
lucknum[i]=zj_huiyuan.Next(1000, 99999);
}
int index = Array.IndexOf(lucknum, sr_huiyuan);
if (index == -1)
{
Console.WriteLine("很遗憾,您没有中奖");
}
else
{
Console.WriteLine("恭喜您,中奖了");
}
Console.WriteLine("");
break;
}
Console.Write("继续吗?(y/n)");
if (Console.ReadLine() == "n")
{ Console.WriteLine("系统退出,谢谢使用"); xuanzhe = false; }
else { continue; }
}
Console.ReadKey();

image.png
网友评论