排列在C号 [英] Permutation for numbers in C

查看:147
本文介绍了排列在C号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图写一个C函数列出一组数字的所有排列,五人一组,其中包括重复号:

I'm trying to write a C function to list all permutations of a set of numbers, in groups of five, including repeat numbers:

15-11-49-43-5
2-30-34-6-11

所以它很容易编写一个函数抢了一些设置,并把他们所有的排列,而是映射到特定组的大小,我有点卡住了。

So it's easy enough to write a function to grab all permutations of a number set and throw them out, but mapped to a certain group size, i'm somewhat stuck..

推荐答案

你想获得一个特定的排列,例如像

Do you want to get a specific permutation, like eg

  • 在置换1 == 1,1,1,1,1
  • 在排列2 == 1,1,1,1,2
  • 在置换49 == 1,1,1,1,49
  • 在置换50 == 1,1,1,2,1
  • 在排列4200 == 8,14,49,35,42

转换你想(减1)立足49,使用数字(加1)数的结果。

Convert the number you want (minus 1) to base 49 and use the "digits" (plus 1) for the result.


42000000 - 1 = 41999999
41999999 = (7 * 49^4) + (13 * 49^3) + (48 * 49^2) + (34 * 49) + 41
result      8            14            49            35         42

这篇关于排列在C号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆