我如何在众多字符串中选择一个并显示所有可能的结果

How can i choose one of the many string and show all possible outcome?

本文关键字:一个 显示 结果 有可能 选择 字符串      更新时间:2023-10-16

我正在尝试生成所有可能的字符串。但是,我需要选择一个字符串或另一个字符串,甚至可能是第三个字符串。我不知道我们如何生成以选择 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
相关文章: