1、制作一个抽奖的程序:
“张三”“李四”“王五”。。。。。
“冰箱”“洗衣机”“”。。。。。
namespace _2017_2_28___数组__抽奖程序 { class Program { static void Main(string[] args) { String [] a=new String []{"洗衣机","电冰箱","电动车","老婆一枚","老公一个","杯子","牙刷"}; String[] b = new string[] { "徐强","郑倩","子轩","子君","郑点","爸爸","妈妈","小狗"}; Random n = new Random(); int d = 0; int c = 0; for (int e = 0; e < b.Length; e++) { Console.Clear(); d = n.Next(0, b.Length); Console.WriteLine("参加抽奖的人员是"+b[e]); System.Threading.Thread.Sleep(1000); } for (int f = 0; f < a.Length; f++) { Console.Clear(); c = n.Next(0, a.Length); Console.WriteLine("奖品有" +a[f]); System.Threading.Thread.Sleep(1000); } Console.Clear(); Console.WriteLine("中奖结果:"+b[d] + ":中奖" + a[c] + "。"); Console.ReadLine(); } } }