返回每个元素限制数组的所有可能性
我想在C中创建一个函数,该函数将参数作为参数作为一个数组,其中每个元素给出范围(从0到存储在数组索引中的数字),我想返回所有可能性
一个例子是,
int elements[2] = [2,4]
int *combinations = combinations(&elements, 2) // 2 being the size of elements
这将给出:
0 0
1 0
0 1
0 2
0 3
1 1
1 2
1 3
我应该如何编码它,以返回一系列数组,以便我可以测试所有组合
I would like to create a function in c that takes in an argument that takes in as an argument an array where for each element it gives the range (from 0 to the number stored at the array index), I would like to return all possibilities
an example would be
int elements[2] = [2,4]
int *combinations = combinations(&elements, 2) // 2 being the size of elements
this would give something along the lines of:
0 0
1 0
0 1
0 2
0 3
1 1
1 2
1 3
I've been stuck as to how I should code it, in order to return an array of arrays so that I can test all combinations possible
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论