新人求帮助啊,关于随机数。。
我想在您获得了几等奖那里加一个1等级3个2等级5个三等奖8个四等奖10个五等奖15个该怎么写?而且不肯能抽中>3个一等奖后面奖励同样。我自己写的for循环定义循环3次有时候只会出1个谢谢惠顾。求高手指点在获得几等奖那里该这么去改.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication15
{
class Program
{
static void Main(string[] args)
{
char c;
string name = "";
string pwd = "";
int cid;
bool is_reg = false;
int jiangping;
bool wancheng = false;
bool denglu = false;
char b;
do
{
Console.WriteLine("**********欢乐透大抽奖系统**********");
Console.WriteLine("\t1、注册\t");
Console.WriteLine("\t2、登陆\t");
Console.WriteLine("\t3、抽奖\t");
Console.WriteLine("************************************");
Console.Write("请选择菜单:");
string choice = Console.ReadLine();
switch (choice)
{
case "1":
if (!is_reg)
{
Console.WriteLine("[欢乐透系统>注册]");
Console.WriteLine("请输入您的注册信息:");
Console.Write("用户名:");
name = Console.ReadLine();
Console.Write("密码:");
pwd = Console.ReadLine();
Random rand = new Random();
cid = rand.Next(1000, 9999);
Console.WriteLine("注册成功,请记住您的会员卡号!");
Console.WriteLine("用户名\t密码\t会员卡号");
Console.WriteLine("{0}\t{1}\t{2}", name, pwd, cid);
is_reg = true;
}
else
{
Console.WriteLine("对不起,您已经注册过了!");
break;
}
break;
case "2":
if (!denglu)
{
Console.WriteLine("[欢乐透系统登录>登陆]");
for (int i = 2; i >= 0; i--)
{
Console.Write("请输入用户名:");
string name1 = Console.ReadLine();
Console.Write("请输入密码:");
string pwd1 = Console.ReadLine();
if (name1 == name && pwd1 == pwd)
{
Console.WriteLine("欢迎你,尊敬的会员{0}登陆成功", name);
denglu = true;
break;
}
else
{
Console.WriteLine("用户名错误,您还有{0}次机会!", i);
}
}
}
else
{
Console.WriteLine("对不起您已经登陆过了!");
}
break;
case "3":
if (!wancheng)
{
Console.WriteLine("[欢乐透系统抽奖>抽奖]");
Console.Write("请登录您的用户名:");
string name2 = Console.ReadLine();
Console.Write("请输入您的密码:");
string pwd2 = Console.ReadLine();
if (name2 == name && pwd2 == pwd)
{
Console.WriteLine("恭喜您登录成功");
for (int j = 3; j >= 0; j--)
{
Console.WriteLine("您还有{0}次抽奖机会", j);
Random jihui = new Random();
jiangping = jihui.Next(1, 50);
Console.WriteLine("是否开始抽奖?(是-y,否-n)");
b = char.Parse(Console.ReadLine());
if (b == 'y')
{
if (jiangping <= 5)
{
Console.WriteLine("恭喜您抽到了{0}等奖", jiangping);
}
else
{
Console.WriteLine("谢谢惠顾");
wancheng = true;
}
}
else
{
Console.WriteLine("谢谢使用!");
break;
}
}
}
else
{
Console.WriteLine("您输入的信息有误请重新输入");
}
}
else
{
Console.WriteLine("对不起您的抽奖机会已经用完!");
}
break;
default:
Console.WriteLine("[对不起,您的输入有误!]");
break;
}
Console.WriteLine("是否继续?(是-y,否n)");
c = char.Parse(Console.ReadLine());
}
while (c == 'y');
Console.ReadLine();
}
}
}