列举如下列所示的组合数前N项和,代码如下(递归方法里注意去重):

     static void Main(string[] args)
{
List<string> list = GetSumOfPermutation("abcde", ).ToList();
File.AppendAllLines(@"C:\Sample.txt", list,Encoding.UTF8);
} static IEnumerable<string> GetSumOfPermutation(string source, int maxCount)
{
string temp = string.Empty;
if (maxCount > )
{
maxCount = maxCount - ;
for (int i = ; i < source.Length; i++)
{
foreach (var cur in GetSumOfPermutation(source, maxCount))
{
if (cur.Contains(source[i]))
continue;
temp = source[i] + cur;
//Console.WriteLine(temp);
yield return temp;
}
temp = source[i].ToString();
//Console.WriteLine(temp);
yield return temp;
}
}
}

使用C#.NET列举组合数前N项和的更多相关文章

  1. POJ 2478 Farey Sequence(欧拉函数前n项和)

    A - Farey Sequence Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u ...

  2. 39. 求分数序列前N项和

    求分数序列前N项和 #include <stdio.h> int main() { int i, n; double numerator, denominator, item, sum, ...

  3. 20. 求阶乘序列前N项和

    求阶乘序列前N项和 #include <stdio.h> double fact(int n); int main() { int i, n; double item, sum; whil ...

  4. 19. 求平方根序列前N项和

    求平方根序列前N项和 #include <stdio.h> #include <math.h> int main() { int i, n; double item, sum; ...

  5. 18. 求交错序列前N项和

    求交错序列前N项和 #include <stdio.h> int main() { int numerator, denominator, flag, i, n; double item, ...

  6. 12. 求简单交错序列前N项和

    求简单交错序列前N项和 #include <stdio.h> int main() { int denominator, flag, i, n; double item, sum; whi ...

  7. 11. 求奇数分之一序列前N项和

    求奇数分之一序列前N项和 #include <stdio.h> int main() { int denominator, i, n; double item, sum; while (s ...

  8. 10. 求N分之一序列前N项和

    求N分之一序列前N项和 #include <stdio.h> int main() { int i, n; double item, sum; while (scanf("%d& ...

  9. 递归函数练习:输出菲波拉契(Fibonacci)数列的前N项数据

    /*====================================================================== 著名的菲波拉契(Fibonacci)数列,其第一项为0 ...

随机推荐

  1. rxjs

    流就是一个事件  或者执行的某些操作

  2. 402 CSS菜鸟:transform and transition

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  3. Max Area of Island

    Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) conn ...

  4. 【转】解决keepalived正常启动但是虚IP(VIP)没有生成的问题

    如题所示,keepalived安装配置好之后能够正常启动,但是虚IP并没有生成.接着检查防火墙(iptables)发现也没有相关的限制.稍微郁闷了一下之后,查看了keepalived日志文件,这次成功 ...

  5. 【原创】大数据基础之词频统计Word Count

    对文件进行词频统计,是一个大数据领域的hello word级别的应用,来看下实现有多简单: 1 Linux单机处理 egrep -o "\b[[:alpha:]]+\b" test ...

  6. 【原创】大数据基础之ElasticSearch(5)重要配置及调优

    Index Settings 重要索引配置 Index level settings can be set per-index. Settings may be: 1 static 静态索引配置 Th ...

  7. SpringBoot Redis缓存 @Cacheable、@CacheEvict、@CachePut

    文章来源 https://blog.csdn.net/u010588262/article/details/81003493 1. pom.xml <dependency> <gro ...

  8. Debian Jessie升级至Stretch小记

    昨天Debian Stretch正式发布.为了尝新,昨天晚上便从Jessie升到了Stretch.结果,早上起来发现系统已无法进入X视窗环境,且NVIDIA的官方驱动无法成功编译和安装.看来,每次系统 ...

  9. linux基础命令学习笔记(一)

    2019年4月1日: “目录” = “文件夹” 常用命令(一): 1.ls: list 列表,默认当前文件夹的文件和目录 linux:命令+选项+参数 ls -l:长输出,列出文件的详细信息 - rw ...

  10. Codeforces 1109D Sasha and Interesting Fact from Graph Theory (看题解) 组合数学

    Sasha and Interesting Fact from Graph Theory n 个 点形成 m 个有标号森林的方案数为 F(n, m) = m * n ^ {n - 1 - m} 然后就 ...