我如何在众多字符串中选择一个并显示所有可能的结果
How can i choose one of the many string and show all possible outcome?
我正在尝试生成所有可能的字符串。但是,我需要选择一个字符串或另一个字符串,甚至可能是第三个字符串。我不知道我们如何生成以选择 BU、AU 或 A 或 B 或 C例如:
BU/AU/AC , A/B/C
Result can be:
BU A
BU B
BU C
AU A
AU B
AU C
etc...
希望我能理解你想要什么(以后更具体(:
#include <iostream>
#include <cstring>
int main()
{
std::string s1[3] = {"A", "B", "C"};
std::string s2[3] = {"Z", "Y", "X"};
for (int i1 = 0; i1 < 3; i1++)
{
for (int i2 = 0; i2 < 3; i2++)
{
std::cout << s1[i1] << " / " << s2[i2];
if ((i1 < 2) || (i2 < 2))
{
std::cout << ", ";
}
else
{
std::cout << std::endl;
}
}
}
}
输出:
A / Z, A / Y, A / X, B / Z, B / Y, B / X, C / Z, C / Y, C / X
相关文章:
- 输入值后,如何在一个括号下显示值,例如"{6,7,8,9}
- 仅显示链表的最后一个元素
- 在 QListView 中显示最后一个元素
- 我在C++中编写了一个方法来打印树类的预序,但它显示了分割错误
- 类中的一个变量显示,但另一个不显示
- 我编写了一个程序来显示数组的内容,但它显示的是它的地址
- 为什么断点显示数组的第二个值是一个大数字?额外学分工作
- 我已经做了一个程序来使用队列链C++表显示学生姓名和身高,现在我想以我不知道如何显示的顺序显示它
- 螺旋矩阵在最后一个"for"循环中中断,不显示任何内容
- 我有一个嵌套数组,它由另一个数组中的元素组成,这些元素分组为2.之后,我想显示每个元素的属性
- 当被一个输入分开时,有两个控制台输出同时显示
- 如何使QLineSeries/QXYSeries仅显示一个点标签
- 如何在 for 循环中显示一个结果
- 在QT C++编辑Qtable模型数据时,我需要得到一个小盒子,我需要显示编辑文本,这怎么可能?
- 如何在QListWidget中显示QStringList的每个项目QLabel和另一个QString?
- 我在视觉工作室中制作了一个类似胭脂的游戏,我想显示玩家的生命值
- C++显示两个区间之间的数字的程序检查一个数字是否可以表示为两个素数的总和
- Gtkmm - 关闭窗口然后显示另一个窗口的正确方法
- 将终端设置为原始模式:仅在按下下一个键后显示字符
- 你如何制作一个显示 24、60 和 1 的向量