双色球中奖判断程序
输入7个数字,如果简洁的判断是否中奖,中了几等奖?我用了IF语句来实现,结果写起来很复杂,有没有简单的实现方法? --------------------编程问答-------------------- 利用一個數組比較
--------------------编程问答-------------------- 排序,然后比较,看有几个相同。 --------------------编程问答-------------------- 都是排序好的。
除了IF语句做判断之外,我想不到更简洁的方法了。 --------------------编程问答-------------------- 程序里面做判断的只有if和swith,还想怎么做啊? --------------------编程问答-------------------- 学习下 --------------------编程问答-------------------- 通过ist<string>保存,再通过匿名方法查询数据 --------------------编程问答-------------------- 不太清楚双色球规则
--------------------编程问答-------------------- http://www.zhcw.com/lottery/db_info.htm
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
String S = "01020811130803";
String T = "01020811130802";
Dictionary<int, String> Numbers = new Dictionary<int, String>
{
{7*2,"一等奖"},
{6*2,"二等奖"},
{5*2,"三等奖"},
};
foreach (KeyValuePair<int, String> N in Numbers)
if (T.Substring(0, N.Key) == S.Substring(0, N.Key))
{
Console.WriteLine(N.Value);
break;
}
Console.Read();
}
}
}
双色球规则这里有详细介绍。 --------------------编程问答-------------------- //获取红球中的个数
public Ing32 GetAwaredRegBallCount(){//TODO:由于双色球的开奖号码和选择的号码是固定长度,建议用数组。array.indexOf来看中了几个球}
//监球是否中奖
public Booleana BlueBallIsAwared(){//TODO:同样用array.indexof}
//看奖等
public AwardLevel(redBallCount,blueIsAwared){//TODO:套用双色球的中奖规则,返回awardLevel枚举}
--------------------编程问答-------------------- 集思广益。再顶起来。
补充:.NET技术 , C#