| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 448 人关注过本帖
标题:新人求帮助啊,关于随机数。。
只看楼主 加入收藏
不会哭的面具
Rank: 2
等 级:论坛游民
帖 子:10
专家分:17
注 册:2012-11-25
收藏
 问题点数:0 回复次数:2 
新人求帮助啊,关于随机数。。
我想在您获得了几等奖那里加一个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();
        }
    }
}
搜索更多相关主题的帖子: void 而且 一等奖 三等奖 四等奖 
2012-11-28 19:36
不会哭的面具
Rank: 2
等 级:论坛游民
帖 子:10
专家分:17
注 册:2012-11-25
收藏
得分:0 
求大神指教啊。敲一下下午循环都没好..
2012-11-28 19:36
qq229943249
Rank: 2
等 级:论坛游民
帖 子:19
专家分:21
注 册:2012-11-6
收藏
得分:0 
把你这个程序需要实现的内容写出来 再来给你分析
2012-12-01 14:17
快速回复:新人求帮助啊,关于随机数。。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.037297 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved