【算法】程序猿不写代码是不对的6
来源:互联网 发布:怪物猎人ol武器数据库 编辑:程序博客网 时间:2024/04/29 06:18
package com.kingdz.algorithm.time201701;/** * 彩票号码由7个1~29的数字组成,7个数字不能重复,生成所有号码的组合<br/> * 算法书上的参考答案,运行依然很慢 * * */public class Algo17 {static int NUM = 29;static int MAXN = 7;static int[] num = new int[NUM];static int[] lottery = new int[MAXN];public static void main(String[] args) {for (int i = 0; i < NUM; i++) {num[i] = i + 1;}for (int j = 0; j < MAXN; j++) {lottery[j] = 0;}combine(NUM, MAXN);}private static void combine(int n, int m) {for (int i = n; i >= m; i--) {lottery[m - 1] = num[i - 1];if (m > 1) {combine(i - 1, m - 1);} else {for (int j = MAXN - 1; j >= 0; j--) {System.out.printf("%3d", lottery[j]);}System.out.println();}}}}
0 0
- 【算法】程序猿不写代码是不对的6
- 【算法】程序猿不写代码是不对的1
- 【算法】程序猿不写代码是不对的2
- 【算法】程序猿不写代码是不对的3
- 【算法】程序猿不写代码是不对的4
- 【算法】程序猿不写代码是不对的5
- 【算法】程序猿不写代码是不对的7
- 【算法】程序猿不写代码是不对的8
- 【算法】程序猿不写代码是不对的9
- 【算法】程序猿不写代码是不对的10
- 【算法】程序猿不写代码是不对的11
- 【算法】程序猿不写代码是不对的12
- 【算法】程序猿不写代码是不对的13
- 【算法】程序猿不写代码是不对的14
- 【算法】程序猿不写代码是不对的15
- 【算法】程序猿不写代码是不对的16
- 【算法】程序猿不写代码是不对的17
- 【算法】程序猿不写代码是不对的18
- mysql导出数据库
- [Leetcode 349]Intersection of Two Arrays
- 回顾文件、目录、设备相关概念
- spring-boot一些概念
- 编写99乘法表的两种方案
- 【算法】程序猿不写代码是不对的6
- Eclipse Neon 下go语言开发插件设置(自行编译插件部署,非update安装)
- 给Java类添加终结器
- 冒泡排序
- 监控系统---使用Ganglia监控MongoDB
- C++ Qt Game Tutorial 0 - Introduction
- 关于RStudio3.3.2 安装包失败
- 数据结构与算法分析笔记与总结(java实现)--链表4:单调链表合并问题
- nodejs实现的爬虫,从百度贴吧爬取小说