您的位置:首页 > 其它

给定一个集合,求出其所有子集合

2006-05-02 18:05 246 查看
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
class Program
/**//// <summary>
/// 函数:给定一个集合,求出其所有子集合
/// </summary>
private static List<string> printList(string[] arr, int num)
if (num < 0)
List<string> reto = new List<string>();
reto.Add("");
return reto;
}
else
List<string> ret = printList(arr, num - 1);
List<string> addRet = new List<string>();
ret.ForEach(delegate(string x) ret.AddRange(addRet);
return ret;
}
}
static void Main(string[] args)
//演示
string[] arr = List<string> ret = printList(arr, 2);
ret.ForEach(delegate(string x) Console.Read();
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐