Dictionary<string, int> dic = new Dictionary<string, int>() { {"七星彩",0}, {"大乐透",0}, {"七乐彩",0}, {"双色球",0} }; DateTime start = Convert.ToDateTime("2011-01-01"); DateTime end = Convert.ToDateTime("2011-12-31"); DateTime temp = start; while (temp <= end) { switch (temp.DayOfWeek) { case DayOfWeek.Monday: { dic["七乐彩"]++; dic["大乐透"]++; break; } case DayOfWeek.Tuesday: { dic["七星彩"]++; dic["双色球"]++; break; } case DayOfWeek.Wednesday: { dic["七乐彩"]++; dic["大乐透"]++; break; } case DayOfWeek.Thursday: { dic["双色球"]++; break; } case DayOfWeek.Friday: { dic["七星彩"]++; dic["七乐彩"]++; break; } case DayOfWeek.Saturday: { dic["大乐透"]++; break; } default: { dic["七星彩"]++; dic["双色球"]++; break; } } temp = temp.AddDays(1); } foreach (String item in dic.Keys) { Console.WriteLine("{0}_{1}", item, dic[item]); }
大哥一如既往的牛
有
强!!!!!!
模拜
哈哈,这是个有趣的问题。
围观~