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

推荐订阅源

N
News and Events Feed by Topic
V
V2EX
博客园 - 【当耐特】
Vercel News
Vercel News
雷峰网
雷峰网
爱范儿
爱范儿
WordPress大学
WordPress大学
云风的 BLOG
云风的 BLOG
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Microsoft Azure Blog
Microsoft Azure Blog
F
Full Disclosure
有赞技术团队
有赞技术团队
Hugging Face - Blog
Hugging Face - Blog
NISL@THU
NISL@THU
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Attack and Defense Labs
Attack and Defense Labs
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Microsoft Security Blog
Microsoft Security Blog
腾讯CDC
P
Proofpoint News Feed
B
Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
K
Kaspersky official blog
I
InfoQ
Google Online Security Blog
Google Online Security Blog
L
LINUX DO - 最新话题
Project Zero
Project Zero
Engineering at Meta
Engineering at Meta
V
Visual Studio Blog
AI
AI
Schneier on Security
Schneier on Security
B
Blog RSS Feed
T
Tor Project blog
H
Help Net Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
LINUX DO - 热门话题
阮一峰的网络日志
阮一峰的网络日志
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Cyber Attacks, Cyber Crime and Cyber Security
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
V2EX - 技术
V2EX - 技术
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
A
Arctic Wolf
Webroot Blog
Webroot Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main

博客园 - 王国营的博客

asp.net Handler中的IsReusable属性及在Handler中使用Session 关于Asp.Net中避免用户连续多次点击按钮,重复提交表单的处理 一道面试题 约瑟夫环问题 不通过第三个变量实现两个整型变量的交换 将PHP文件生成静态文件源码 PHP Warning: date(): It is not safe to rely on the system's timezone settings EcShop 如何制作一张windows sp3启动安装盘iso? win7下xp mode IP在同一网段实现网络共享 sql server 2005附加数据库错误 无法打开物理文件 解决114啦源码(114la)不能生成地方房产和地方报刊问题4级页面0字节 菜鸟学PHP之Smarty入门(组图) 弹出一次“设为主页”和“加入收藏”代码 EMS SQL Manager中文显示乱码的解决方法 未在本地计算机上注册“Microsoft.Jet.OLEDB.4.0”提供程序 CSS和JS链接地址中带的问号是做什么的 IIS7/IIS7.5下轻松配置PHP利器(微软PHP Manager for IIS 7) iframe异步加载技术及性能 新开网址导航网站,欢迎各位朋友捧场
多层循环的递归实现
王国营的博客 · 2013-12-02 · via 博客园 - 王国营的博客

C#实现 

class Program
{
static string temp = "";
static int count = 0;
static void Main(string[] args)
{
int[] arr = {1,2,3,4,5,6,7,8};
GetNumber(arr,5,"","");
}
public static void GetNumber(int[] array, int round, string strNum,string preStrNum)
{
for (int i = 0; i < array.Length; i++)
{
temp = strNum;
if (round == 1)
{
temp += array[i].ToString();
string[] strs = temp.Split(' ');
int sum = 0;
foreach (var item in strs)
{
sum += int.Parse(item);
}
temp =string.Join("+",strs) +"="+sum;
Console.WriteLine(temp);
}
else
{
string s = strNum;
strNum += array[i].ToString() + " ";
GetNumber(array, round - 1, strNum, s);
strNum = s;
}
}
}

}