zoukankan      html  css  js  c++  java
  • 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();

  • 相关阅读:
    从零入门 Serverless | 教你 7 步快速构建 GitLab 持续集成环境
    4 个场景揭秘,如何低成本让容器化应用 Serverless 化?
    如何无缝迁移 SpringCloud/Dubbo 应用到 Serverless 架构
    精准容量、秒级弹性,压测工具 + SAE 方案如何完美突破传统大促难关?
    golang 实现最小二乘法拟合直线
    golang 实现两数组对应元素相除
    js 算数组平均值、最大值、最小值、偏差、标准差、中位数、数组从小打大排序、上四分位数、下四分位数
    ajax传数组后台GO语言接收
    python 画图中文显示问题
    python stats画正态分布、指数分布、对数正态分布的QQ图
  • 原文地址:https://www.cnblogs.com/jlhea/p/4822850.html
Copyright © 2011-2022 走看看