本文介绍了如何在 C++ 中创建多个向量的组合而无需硬编码循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
我有几个看起来像这样的数据:
I have several data that looks like this:
我想要做的是在 Vector1 到 VectorK 中创建所有元素组合.因此最终我们希望得到这个输出(使用 Vector1,2,3):
What I want to do is to create all combination of elements in Vector1 through out VectorK. Hence in the end we hope to get this output (using Vector1,2,3):
我现在遇到的问题是我的以下代码通过对循环进行硬编码来实现.由于向量的数量可以变化,我们需要一种灵活的方法来获得相同的结果.有吗?
The problem I am having now is that the following code of mine does that by hardcoding the loops. Since number of Vectors can be varied, we need a flexible way to get the same result. Is there any?
我的这段代码最多只能处理 3 个向量(硬编码):
This code of mine can only handle up to 3 Vectors (hardcoded):
推荐答案
这样做可以解决问题:
致电:
这篇关于如何在 C++ 中创建多个向量的组合而无需硬编码循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!