标签:
1.手机号抽奖
Console.WriteLine("请输入手机号的个数:"); int a = Convert.ToInt32(Console.ReadLine()); string[] sj = new string[a]; for (int i = 0; i < a; i++) { Console.WriteLine("请输入第{0}个手机号:", i + 1); sj[i] = Console.ReadLine(); } Console.WriteLine("**********************"); //抽奖 DateTime t = DateTime.Now; DateTime tt = t.AddSeconds(10); while (true) { Console.Clear(); Random r = new Random(); int b = r.Next(a); Console.WriteLine(sj[b]); Thread.Sleep(60); if (DateTime.Now.ToString("yyyyMMddhhmmss") == tt.ToString("yyyyMMddhhmmss")) { break; } else { } } Console.ReadLine();
2.福利彩票随机生成
Random n = new Random(); int lan = n.Next(0,17); int [] hong=new int[6]; int a = 0; while (true) { if (a == 6) { break; } else { int b = n.Next(0,34); if (hong.Contains(b)) { } else { hong[a]=b; a++; } } } for (int i = 0; i < hong.Length - 1; i++) { for (int j = 0; j < hong.Length - 1 - i; j++) { if (hong[j] >= hong[j + 1]) { int zj = hong[j]; hong[j] = hong[j+1]; hong[j + 1] = zj; } } } Console.Write("红球为"); for (int z = 0; z < a; z++) { Console.Write(hong[z] + ","); } Console.WriteLine(); Console.WriteLine("蓝球为"+lan); }
标签:
原文地址:http://www.cnblogs.com/jia520110270/p/4649781.html