• 0916,双色球练习题


     while (true)            

    {                

    int[] shuzu = new int[7];                

    Random r = new Random();

                   

    for (int i = 0; i < 6; i++)                

    {                    

    shuzu[i] = r.Next(1, 32);

                       

    bool isok = false;                    

    for (int j = 0; j < i; j++)                    

    {                        

    if (shuzu[j] == shuzu[i])                        

    {                            

    isok = true;                        

    }                    

    }                    

    if (isok)                    

    {                        

    i--;                        

    continue;                    

    }                

    }                

    shuzu[6] = r.Next(1, 32);

                   

    Console.Write("请输入红球和篮球,用逗号隔开:");

                   

    string shuru = Console.ReadLine();                

    string[] ren = shuru.Split(',');

                   

    int count = 0;                

    for (int i = 0; i < 6; i++)                

    {                    

    for (int j = 0; j < 6; j++)                    

    {                        

    if (int.Parse(ren[i]) == shuzu[j])                        

    {                            

    count++;                        

    }                    

    }                

    }                

    bool islan = false;                

    if (int.Parse(ren[6]) == shuzu[6])                

    {                    

    islan = true;                

    }

                   

    foreach (int a in shuzu)                

    {                    

    Console.Write(a + " | ");                

    }

                   

    if (count == 6 && islan)                

    {                    

    Console.WriteLine("一等奖");                

    }                

    else if (count == 6 && !islan)                

    {                    

    Console.WriteLine("二等奖");                

    }                

    else if (count == 5 && islan)                

    {                    

    Console.WriteLine("三等奖");                

    }                

    else if ((count == 5 && !islan) || (count == 4 && islan))                

    {                    

    Console.WriteLine("四等奖");                

    }                

    else if ((count == 4 && !islan) || (count == 3 && islan))                

    {                    

    Console.WriteLine("五等奖");                

    }                

    else if ((count == 2 && islan) || (count == 1 && islan) || (count == 0 && islan))                

    {                    

    Console.WriteLine("六等奖");                

    }                

    else                

    {                    

    Console.WriteLine("未中奖");                

    }

                    Console.ReadLine();

  • 相关阅读:
    Win32的开发过程
    Win32的开发过程
    内存模式
    在DOS下生成一个可执行文件一般步骤
    内存模式
    内存模式
    静态链接
    在DOS下生成一个可执行文件一般步骤
    备忘录模式(存档模式)
    建造者模式
  • 原文地址:https://www.cnblogs.com/jlhea/p/4822850.html
Copyright © 2020-2023  润新知