惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Vulnerabilities – Threatpost
U
Unit 42
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
F
Full Disclosure
月光博客
月光博客
Engineering at Meta
Engineering at Meta
博客园_首页
The Register - Security
The Register - Security
G
Google Developers Blog
The Cloudflare Blog
博客园 - Franky
K
Kaspersky official blog
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
C
Check Point Blog
NISL@THU
NISL@THU
AI
AI
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Vercel News
Vercel News
T
Tor Project blog
P
Privacy International News Feed
D
Docker
I
Intezer
L
LangChain Blog
P
Proofpoint News Feed
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
博客园 - 聂微东
AWS News Blog
AWS News Blog
Martin Fowler
Martin Fowler
P
Privacy & Cybersecurity Law Blog
V
V2EX
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
The Hacker News
The Hacker News
T
Tenable Blog
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog

博客园 - 登峰

VS2010 工具箱装载出错 将用户导入到membership 网络和笔记本 用live writer写博客 javascript写计数器 - 登峰 - 博客园 上海招聘.net程序员 Virtual Machine--Vmware(2) Virtual Machine -- VmWare(1) 代码自动生成操作 - 登峰 - 博客园 病毒惹的祸 一道受用终身的测试题 慎用优化工具 一个简单的存储过程代码生成器 DataGrid的Bug? 哪个是最好的ORM C#设计模式---概述篇 还原master数据库 Sql Server实用操作小技巧集合(转载) .net 程序发生了一个不可捕获的异常
n取的r的组合数问题
登峰 · 2005-06-17 · via 博客园 - 登峰

下午在逛BBS的时候,发现一个小小的算法问题,觉得有趣,便花了点时间简单的写了一下(时间是挤出来的嘛:)
网友的问题如下:

我可能没说清楚,
比如有1,2,3,4,5,6,7这7个数字:
他们的任意6个数字的组合只能有下面几种情况:
1 2 3 4 5 6
1 3 4 5 6 7
1 2 4 5 6 7
1 2 3 5 6 7
1 2 3 4 6 7
1 2 3 4 5 7
2 3 4 5 6 7
对吧~
但是数字越多出先的组合也越多~所以想做个程序把这些组合给找出来~

这问题用递归即可解决, 代码如下
public class CodeForComb

 { 
        static int [] CombData=new int[10];

             static void Main()
                                          {  
                                     a[0]=6;//打印6个数
                                               comb(7,6); //按7中取6个不同的组合数

                                            }


  static void comb(int m,int k)
  {
           int i,j;
           for( i=m;i>=k;i--)
               {       
                    CombData[k]=i;
                    if(k>1)
                     comb(i-1,k-1);//还有其他组合数 递归

                    else  //有一组组合数了
                        {
                         for(j=a[0];j>0;j--)
                             {
                                  Console.Write(CombData[j]);
                               }
                         Console.WriteLine();
     
                        }//else
           
                }//for
     } //comb
 }//class