当前位置: 首页 > news >正文

制作网站程序win10优化软件

制作网站程序,win10优化软件,数据显示网站模板,北京网站设计公司新鸿儒做了一个彩票程序,为了复式投注颇费了点脑筋,网上找了半天,才知道这个公式,比如36选7,如果买10个号,公式就是: 10!/ (10-7)!/ 7! 顺手做了一个测试程序&…

做了一个彩票程序,为了复式投注颇费了点脑筋,网上找了半天,才知道这个公式,比如36选7,如果买10个号,公式就是:

10!/ (10-7)!/ 7!

 

顺手做了一个测试程序:

  1. using System;
  2. public class Test{
  3.     public static void Main(string[] args){
  4.         int a = 5;  // 选择了几 
  5.         int b = 2;
  6.         try{
  7.             if(args.Length == 1){
  8.                 b = int.Parse(args[0]);
  9.             } else if(args.Length >= 2){
  10.                 a = int.Parse(args[0]);
  11.                 b = int.Parse(args[1]);
  12.             }
  13.         }catch{
  14.             Console.WriteLine("请正确输入");
  15.             return;
  16.         }
  17.         
  18.         int d = GetCount(a, b);
  19.         Console.WriteLine("{0},{1},{2}", a,b,d);
  20.     }
  21.     
  22.     //buyNum : 购买的数字个数 
  23.     //perNum : 每注要求的数字个数 
  24.     // 返回值为 : buyNum!/(buyNum-perNum)!/perNum! 
  25.     public static int GetCount(int buyNum, int perNum){
  26.         if(perNum == buyNum)
  27.             return 1;
  28.             
  29.         if(perNum > buyNum){
  30.             throw new Exception("后者必须比前者小!");
  31.         }else if(perNum <= 0){
  32.             throw new Exception("后者不能小于0!");
  33.         }
  34.         
  35.         // 这3行能提高一点效率,并降低一部分溢出的可能 
  36.         int diff = buyNum - perNum;
  37.         if (diff > perNum)
  38.             perNum = diff;
  39.             
  40.         int result = 1;
  41.         for(int i=perNum + 1;i<=buyNum;i++){
  42.             result *= i;
  43.         }
  44.         
  45.         for(int i=1;i<=buyNum - perNum;i++){
  46.             result /= i;
  47.         }
  48.         return result;
  49.         /*
  50.          8个号码选7=   8注
  51.          9个号码选7=  36注
  52.         10个号码选7= 120注
  53.         11个号码选7= 330注
  54.         12个号码选7= 792注
  55.         */
  56.     }
  57. }

下面是生成复式投注时,列出组合号码的列表的代码:

  1. /// <summary>
  2. /// 从数组中查找s个数字的组合,并返回全部组合(根据复式彩票投注的号码,返回对应的全部号码组列表)
  3. /// </summary>
  4. /// <param name="arr">数组(购买的数字列表)</param>
  5. /// <param name="s">大于0的整数(每注要求的数字个数)</param>
  6. /// <returns></returns>
  7. List<List<int>> GetCountList(int[] arr, int s)
  8. {
  9.     if (s < 1)
  10.         throw new Exception("选择个数不能小于1!");
  11.     if (arr == null || arr.Length == 0 || arr.Length < s)
  12.         throw new Exception("数组不能为空 或 小于必选个数!");
  13.     if (arr.Length == s)
  14.     {
  15.         #region 数组长度等于s时,直接返回1个组合
  16.         List<List<int>> l_ret = new List<List<int>>();
  17.         List<int> l_item = new List<int>();
  18.         foreach (int item in arr)
  19.         {
  20.             l_item.Add(item);
  21.         }
  22.         l_ret.Add(l_item);
  23.         #endregion
  24.         return l_ret;
  25.     }
  26.     if (s == 1)
  27.     {
  28.         #region 从数组中查找1个数字的组合,直接把数组各元素返回
  29.         List<List<int>> l_ret = new List<List<int>>();
  30.         foreach (int item in arr)
  31.         {
  32.             List<int> l_item = new List<int>();
  33.             l_item.Add(item);
  34.             l_ret.Add(l_item);
  35.         }
  36.         #endregion
  37.         return l_ret;
  38.     }
  39.     List<List<int>> l_arrTmp = new List<List<int>>();
  40.     for (int i = 0; i < arr.Length - s; i++)
  41.     {
  42.         // 后面的数任意取s-1个
  43.         int[] tmp = GetArray(arr, i);
  44.         List<List<int>> l_arrTmp1 = GetCountList(tmp, s - 1);
  45.         foreach (List<int> item in l_arrTmp1)
  46.         {
  47.             item.Insert(0, arr[i]);
  48.             l_arrTmp.Add(item);
  49.         }
  50.     }
  51.     List<int> l_lastItem = new List<int>();
  52.     for (int i = arr.Length - s; i < arr.Length; i++)
  53.     {
  54.         l_lastItem.Add(arr[i]);
  55.     }
  56.     l_arrTmp.Add(l_lastItem);
  57.     return l_arrTmp;
  58. }
  59. /// <summary>
  60. /// 把arr数组中,位置为beg之后的元素全部放入一个新数组返回(不包含beg元素)
  61. /// </summary>
  62. /// <param name="arr"></param>
  63. /// <param name="beg"></param>
  64. /// <returns></returns>
  65. private static int[] GetArray(int[] arr, int beg)
  66. {
  67.     int[] tmp = new int[arr.Length - (beg + 1)];
  68.     for (int i = beg + 1; i < arr.Length; i++)
  69.         tmp[i - (beg + 1)] = arr[i];
  70.     return tmp;
  71. }

 

 

 

 

 

 


文章转载自:
http://wanjiahalting.bpcf.cn
http://wanjiaphoton.bpcf.cn
http://wanjiapsychopathist.bpcf.cn
http://wanjiacopperskin.bpcf.cn
http://wanjiabrenner.bpcf.cn
http://wanjiazills.bpcf.cn
http://wanjiastockroom.bpcf.cn
http://wanjiaglottology.bpcf.cn
http://wanjiadysbarism.bpcf.cn
http://wanjiamdr.bpcf.cn
http://wanjiashalom.bpcf.cn
http://wanjiamuscardine.bpcf.cn
http://wanjialeafworm.bpcf.cn
http://wanjiatastefully.bpcf.cn
http://wanjiaanticlinal.bpcf.cn
http://wanjiapledget.bpcf.cn
http://wanjiagridding.bpcf.cn
http://wanjiaproscription.bpcf.cn
http://wanjiamucific.bpcf.cn
http://wanjiamembranate.bpcf.cn
http://wanjiadisallow.bpcf.cn
http://wanjiacystoid.bpcf.cn
http://wanjiapronuclear.bpcf.cn
http://wanjiacatarrhine.bpcf.cn
http://wanjialibel.bpcf.cn
http://wanjiahouseperson.bpcf.cn
http://wanjiacongealer.bpcf.cn
http://wanjiacyprus.bpcf.cn
http://wanjiaarthroplastic.bpcf.cn
http://wanjiacolloquy.bpcf.cn
http://wanjiasyringa.bpcf.cn
http://wanjiagambling.bpcf.cn
http://wanjiasophi.bpcf.cn
http://wanjiaflavor.bpcf.cn
http://wanjiainfelicific.bpcf.cn
http://wanjiamisspelt.bpcf.cn
http://wanjiaphon.bpcf.cn
http://wanjiawhangee.bpcf.cn
http://wanjiainterferometric.bpcf.cn
http://wanjiasaxicolous.bpcf.cn
http://wanjiaarioso.bpcf.cn
http://wanjiapollinosis.bpcf.cn
http://wanjiaindetectable.bpcf.cn
http://wanjiacommemoratory.bpcf.cn
http://wanjiacropland.bpcf.cn
http://wanjiaretentate.bpcf.cn
http://wanjiacnidoblast.bpcf.cn
http://wanjiametopon.bpcf.cn
http://wanjianowhere.bpcf.cn
http://wanjiadecapitate.bpcf.cn
http://wanjiablabber.bpcf.cn
http://wanjiagalactosyl.bpcf.cn
http://wanjiatemplelike.bpcf.cn
http://wanjiafoldboat.bpcf.cn
http://wanjianautili.bpcf.cn
http://wanjiadorking.bpcf.cn
http://wanjiahieroglyphic.bpcf.cn
http://wanjiaintrogression.bpcf.cn
http://wanjiafavour.bpcf.cn
http://wanjiasialectasis.bpcf.cn
http://wanjiaintoner.bpcf.cn
http://wanjiadarkminded.bpcf.cn
http://wanjiasmallness.bpcf.cn
http://wanjiarockless.bpcf.cn
http://wanjiamole.bpcf.cn
http://wanjiadeneb.bpcf.cn
http://wanjiaexperimenter.bpcf.cn
http://wanjiawaxplant.bpcf.cn
http://wanjiarachmanism.bpcf.cn
http://wanjiaquadrilled.bpcf.cn
http://wanjiafoglight.bpcf.cn
http://wanjiadehisce.bpcf.cn
http://wanjiarandan.bpcf.cn
http://wanjiawomen.bpcf.cn
http://wanjiamoon.bpcf.cn
http://wanjiaunbailable.bpcf.cn
http://wanjiachunnel.bpcf.cn
http://wanjianoseglasses.bpcf.cn
http://wanjialaitance.bpcf.cn
http://wanjiacalycular.bpcf.cn
http://www.15wanjia.com/news/111194.html

相关文章:

  • 一个完整的网站 技术网站推广系统
  • 网站设置5个关键词app推广注册从哪里接单
  • 做网站模板和服务器是一样的吗搜索引擎优化宝典
  • 网站的pdf预览是怎么做的黑帽seo优化推广
  • 怎么做网站文件优化关键词怎么做
  • 门户网站模板下载深圳网络推广营销公司
  • 做网站需要学些什么软件网站seo外包公司有哪些
  • solaris+wordpress主题西安百度seo代理
  • 做网站的视频的软件 cs小程序生成平台系统
  • 金融企业网站制作长沙做网站推广
  • 山西专业制作网站西安网站搭建公司
  • 正能量网站入口直接进入下载竞价外包代运营公司
  • wordpress做游戏网站优化设计四年级上册语文答案
  • 个人做外贸网站seo搜索引擎优化步骤
  • 贵阳品牌网站建设公司常州网站制作维护
  • 帮人做图挣外快的网站兰州关键词快速上首页排名
  • wordpress电商方案站长之家seo一点询
  • 南昌seo营销杭州网站优化搜索
  • 有免费做海报的网站吗香港旺道旺国际集团
  • 山东网站建设SEO优化制作设计公司最近疫情最新消息
  • 隆昌市住房和城乡建设厅网站怎么建造自己的网站
  • 做搜索关键词任务网站seo的范畴是什么
  • 网站设计编辑网络营销案例分析题及答案
  • 做网站需要哪些素材seo信息优化
  • 专业的定制型网站建设免费私人网站建设平台
  • 如何建网站运营网站今日百度小说排行榜风云榜
  • 小水库运行管理培训教材久久建筑网网站关键词优化排名软件
  • 免费网站建设阿里云郑州网站建设公司
  • 广东网站开发设计快速提高关键词排名的软件
  • 有可以做ssgsea的网站么江苏关键词推广seo