using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { //class bf //{ // /// <summary> // /// 类型名 // /// </summary> // public string name { set; get; } // /// <summary> // /// 总和球 // /// </summary> // public int sum { set; get; } // /// <summary> // /// 相差球 // /// </summary> // public int diff { set; get; } // /// <summary> // /// 胜平负 // /// </summary> // public int spf { set; get; } // /// <summary> // /// 数据集合 // /// </summary> // public Dictionary<string,int> maxofttt { set; get; } //} class Class1 { /// <summary> /// 初始化 Ga di! /// </summary> public void csh() { List<bf> algo = new List<bf>(); int i = 0; for (; i < 6; i++) { for (int j = 0; j < 6; j++) { if (i == 3 && j > 3 || i > 3 && j > 2) { continue; } algo.Add(new bf() { name= i + "" + j, sum= i + j, diff= Math.Abs(i - j), spf= i > j ? 3 : (i < j ? 0 : 1) }); } } Dictionary<string, int>[] sus = new Dictionary<string, int>[100]; for (i = algo.Count;i>=0 ; i--) { bf bff = algo[i]; Dictionary<string, int> oft = new Dictionary<string, int>(); oft.Add("bf - " + bff.name, 1); oft.Add("sum-" + bff.sum, 1); oft.Add("spf-" + bff.spf, 1); if (bff.spf == 3) { if (bff.sum > 2) { oft.Add("bqc-03", 1);} oft.Add("bqc-13", 1); oft.Add("bqc-33", 1); } else if (bff.spf == 1) { if (bff.sum > 1) { oft.Add("bqc-01", 1); oft.Add("bqc-31", 1); } oft.Add("bqc-11", 1); } else if (bff.spf == 1) { oft.Add("bqc-00", 1); oft.Add("bqc-10", 1); if (bff.sum > 2) { oft.Add("bqc-30", 1); } } sus[i] = oft; } } } //var algo = this, allBf = [], len = 0, bfCheckMap = { }; // allBf.push({ name: ‘3A‘,sum: 7, spf: 3}, { name: ‘1A‘,sum: 7,spf: 1},{ name: ‘0A‘,sum: 7,spf: 0}); }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { /// <summary> /// 所有可能比分 /// </summary> public static Dictionary<string, int>[] sus; /// <summary> /// 要遍历的次数名字!!! /// </summary> public static List<bf> algo; /// <summary> /// 初始化所有情况 /// </summary> public static void csh() { algo = new List<bf>(); int i = 0; for (; i < 6; i++) { for (int j = 0; j < 6; j++) { if (i == 3 && j > 3 || i > 3 && j > 2) { continue; } algo.Add(new bf() { bileft = i, biright = j, name = i + "" + j, sum = i + j, diff = Math.Abs(i - j), spf = i > j ? 3 : (i < j ? 0 : 1) }); } } //加上大于7的可能 默认为9 algo.Add(new bf() { name = "39", bileft = 3, biright = 9, sum = 7, spf = 3 }); algo.Add(new bf() { name = "19", bileft = 1, biright = 9, sum = 7, spf = 1 }); algo.Add(new bf() { name = "09", bileft = 0, biright = 9, sum = 7, spf = 0 }); sus = new Dictionary<string, int>[100]; for (i = algo.Count - 1; i >= 0; i--) { bf bff = algo[i]; Dictionary<string, int> oft = new Dictionary<string, int>(); oft.Add("bf-" + bff.name, 1); oft.Add("sum-" + bff.sum, 1); oft.Add("spf-" + bff.spf, 1); if (bff.spf == 3) { if (bff.sum > 2) { oft.Add("bqc-03", 1); } oft.Add("bqc-13", 1); oft.Add("bqc-33", 1); } else if (bff.spf == 1) { if (bff.sum > 1) { oft.Add("bqc-01", 1); oft.Add("bqc-31", 1); } oft.Add("bqc-11", 1); } else if (bff.spf == 0) { oft.Add("bqc-00", 1); oft.Add("bqc-10", 1); if (bff.sum > 2) { oft.Add("bqc-30", 1); } } sus[i] = oft; } } static void Main(string[] args) { csh();//初始化 // 数据传递格式 // sfp 胜负平 bf 比分 rsfp 让球胜负平 sum 总球数 bqc 半全场 #后面跟倍率 & 区分玩法 ,是玩法的类型区分 //胜 是3 平 1 负 0 //bqc 传递数据格式 如 平胜 平是2胜是3 就传 13 胜胜 33 平平 11 // bf 如果 1:2 传 12 //数据格式 rspf-3#1.31,rspf-1#1.1&spf-3#1.98 &bf-10#8.25& sum-0#21.00 &bqc-33#1.70 //没有的数据默认 rspf-9#0&spf-9#0.... 没有数据全部默认传9 并且 大概率 如7:7 以上的 统统传9 var tt = money(1, "rspf-3#1.46,rspf-1#3.65,rspf-0#5.85&spf-1#2.72&bf-11#6.00&sum-2#2.95&bqc-13#5.50"); //方法可以返回 最大最小金额的 所有复合方案 数组组后可以看最小最大金额 Console.WriteLine("最大金额方案"); foreach (var item in tt[0] as string[]) { if (string.IsNullOrEmpty(item)) { break; } Console.WriteLine(item);//最大金额所有符合的方案 } Console.WriteLine("最小金额方案"); foreach (var item in tt[1] as string[]) { if (string.IsNullOrEmpty(item)) { break; } Console.WriteLine(item);//最小金额所有符合的方案 } } /// <summary> /// 最大金额 最小金额 计算 /// </summary> /// <param name="rq">让球</param> /// <param name="xx">数据格式</param> /// <returns></returns> public static object[] money(int rq, string xx) { string[] maxmin = new string[10];//存当前满足条件情况的倍率 string[] maxto = new string[10];//最大钱倍率 string[] minto = new string[10];//最小钱倍率 int mmint = 0;//初始下标 decimal mins = 0, maxs = 0, csh = 0;//上面三个的初始赋值 int cs = 0;//名字 string[] rot = new string[45];//存所有情况 string[] rrot = new string[3];//存让球情况 int xt = 0, xr = 0;//所有情况下标 和让球情况下标 string[] a = xx.Split(‘&‘);//把玩法分开 //把所有数据进行统计和 for (int k = 0; k < a.Length; k++) { string[] b = a[k].Split(‘,‘); for (int i = 0; i < b.Length; i++)//去每个选项的名字 和 赔率 { if (b[i].Substring(0, 2) == "rs") { rrot[xr] = b[i]; xr++; } else { rot[xt] = b[i]; xt++; } } } decimal mo = 1; foreach (var item in sus) { if (item == null) { break; } for (int k = 0; k < rrot.Length; k++) { if (string.IsNullOrEmpty(rrot[k])) { break; } int jiequ = rrot[k].Split(‘#‘)[0].Length; if (algo[cs].bileft - algo[cs].biright + rq > 0 && int.Parse(rrot[k].Split(‘#‘)[0].Substring(jiequ - 1, 1)) == 3) { maxmin[mmint] = rrot[k]; mmint++; mo *= decimal.Parse(rrot[k].Split(‘#‘)[1]); } if (algo[cs].bileft - algo[cs].biright + rq == 0 && int.Parse(rrot[k].Split(‘#‘)[0].Substring(jiequ - 1, 1)) == 1) { maxmin[mmint] = rrot[k]; mmint++; mo *= decimal.Parse(rrot[k].Split(‘#‘)[1]); } if (algo[cs].bileft - algo[cs].biright + rq < 0 && int.Parse(rrot[k].Split(‘#‘)[0].Substring(jiequ - 1, 1)) == 0) { maxmin[mmint] = rrot[k]; mmint++; mo *= decimal.Parse(rrot[k].Split(‘#‘)[1]); } } for (int i = 0; i < rot.Length; i++) { if (string.IsNullOrEmpty(rot[i])) { break; } if (item.Any(c => c.Key.Contains(rot[i].Split(‘#‘)[0]))) { maxmin[mmint] = rot[i]; mmint++; mo *= decimal.Parse(rot[i].Split(‘#‘)[1]); } } if (csh == 0 && mo != 1) { maxs = mo; mins = mo; maxmin.CopyTo(maxto, 0); maxmin.CopyTo(minto, 0); csh = 1; } if (mo != 1 && mo > maxs) { maxs = mo; maxto = new string[10]; maxmin.CopyTo(maxto, 0); } if (mo != 1 && mo < mins) { mins = mo; minto = new string[10]; maxmin.CopyTo(minto, 0); } mo = 1;//初始化金额 maxmin = new string[10];//清空数组 mmint = 0;//数组小标清空 cs++; } return new object[2] { maxto, minto }; } } class bf { /// <summary> /// 比分名字 /// </summary> public string name { set; get; } /// <summary> /// 模拟左比分 /// </summary> public int bileft { set; get; } /// <summary> /// 模拟右比分 /// </summary> public int biright { set; get; } /// <summary> /// 总和球 /// </summary> public int sum { set; get; } /// <summary> /// 相差球 /// </summary> public int diff { set; get; } /// <summary> /// 胜平负 /// </summary> public int spf { set; get; } } }
原文地址:https://www.cnblogs.com/yuanzijian-ruiec/p/10295929.html
时间: 2024-10-20 11:49:10