• 用c#控制台模拟双色球随机选


    代码
     1  
     2 
     3 
     4 using System;
     5 
     6 using System.Collections.Generic;
     7 
     8 using System.Linq;
     9 
    10 using System.Text;
    11 
    12 using System.Threading;//线程命名空间必需引用
    13 
    14 using System.Collections;//集全命名空间必需引用
    15 
    16 using System.Collections.Generic;
    17 
    18 using System.Text.RegularExpressions;
    19 
    20 using System.Data.SqlClient;
    21 
    22 static void 双色球()
    23 
    24 {ArrayList redbollbox = new ArrayList();//设置一个装红球箱
    25 
    26 ArrayList redboll = new ArrayList();//设置一个装已滚出来的红球箱
    27 
    28 ArrayList bluebollbox = new ArrayList();//设置一个装蓝球箱
    29 
    30 object blueboll;//出来的蓝球
    31 
    32 for (int i = 1; i <= 33; i++)//给红球写号
    33 
    34 {
    35 
    36 redbollbox.Add(i);
    37 
    38 }
    39 
    40 for (int i = 1; i <= 16; i++)//给蓝球写号
    41 
    42 {
    43 
    44  bluebollbox.Add(i);
    45 
    46 }
    47 
    48 Console.WriteLine("红球滚动中");
    49 
    50 for (int i = 0; i < 6; i++)//滚球
    51 
    52 
    53 
    54 Thread.Sleep(5000);//滚球等待
    55 
    56 int outboll = new Random().Next(0, redbollbox.Count - 1);//随机选球的编号                
    57 
    58 redboll.Add(redbollbox[outboll]);//出来的球
    59 
    60 Console.WriteLine("第{0}个球:{1}", i + 1, redboll[i]);//滚出的球号是几
    61 
    62 redbollbox.RemoveAt(outboll);//去掉出来的球               redbollbox.TrimToSize();//球箱的球减少
    63 
    64 }
    65 
    66 Console.WriteLine("蓝球滚动中");
    67 
    68 Thread.Sleep(5000);
    69 
    70 blueboll = bluebollbox[new Random().Next(0, bluebollbox.Count - 1)];
    71 
    72 Console.WriteLine("最后的蓝球是:{0}", blueboll);
    73 
    74 redboll.Sort();//红球排序
    75 
    76 Console.Write("红球区:");
    77 
    78 foreach (object item in redboll)
    79 
    80 { Console.Write("{0} ", item);}
    81 
    82 Console.Write(" 蓝球号:{0}\n", blueboll);
    83 
    84 }
    85 
    86  
    87 
  • 相关阅读:
    docker-compose 命令详解
    Ubuntu 安装 rabbitmq
    scrapy.cmdline.execute
    queue.Queue()
    多线程通信
    多线程(thread+queue 售票)
    协程
    线程
    利用Nginx实现反向代理web服务器
    利用Nginx实现反向代理web服务器
  • 原文地址:https://www.cnblogs.com/Witkey/p/1628786.html
Copyright © 2020-2023  润新知