小编use*_*982的帖子

功能给出错误的结果

我已经尝试编写以下函数来通过从算法文本中转换算法来生成字符串的所有组合.但它会在输出中为所有组合打印整个字符串.

len = strlen(str);
for(i=0;i<pow(2,len);i++) 
{
        for(j=0;j<len;j++) 
        {
                if(i && (0x1 << j)) 
                {
                        cout<<str[j];
                }
        }
        cout<<endl;
}
Run Code Online (Sandbox Code Playgroud)

谢谢大家.

c++ algorithm combinations operators

2
推荐指数
1
解决办法
123
查看次数

标签 统计

algorithm ×1

c++ ×1

combinations ×1

operators ×1