求集合的子集
来源:互联网 发布:大数据公司排名北京 编辑:程序博客网 时间:2024/05/22 05:22
利用递归算法
#include <iostream>#include<string>using namespace std;void trail(string[],int[],int,int);int main(){ int n,k=0; cout<<"Please enter the number of the element :"; cin>>n; string a[100]; int b[100]={0}; for (int i=0;i<n;i++) { cout<<"Please enter NO."<<i+1<<" element :"; cin>>a[i]; } cout<<"All of the subset is:"<<endl; trail(a,b,0,n); return 0; }void trail(string a[],int b[],int k,int n){ int j; if (k<n) { trail(a,b,k+1,n); b[k]=1-b[k]; trail(a,b,k+1,n); } else { cout<<"{"; for (j=0;j<=n;j++) { if (b[j]) { cout<<a[j]<<" "; } } cout<<"} "; } }
0 0
- 求集合的子集
- 求集合的子集
- 求集合的子集
- 求集合的子集
- 求集合的子集
- 求集合的子集
- 求集合的全部子集
- 求集合的所有子集
- 求集合子集的算法
- 求集合的所有子集
- 求一个集合的子集
- 求集合的所有子集
- 求集合的所有子集
- 求集合的所有子集
- 求一个集合的子集,子集元素数目固定
- 求集合的所有子集的算法
- 求集合的所有子集的算法
- 用递归方法求集合的子集
- syslog相关
- 【原创】Redis内核之数据结构实现
- 第12周 【项目4 - 点、圆的关系】(1)
- 5555555555555555555555555
- ubuntu linux入门
- 求集合的子集
- CocoaPods使用详细说明
- 【java的多态性】
- 根据对象的某个属性给他个class属性
- 想要UGUI和Spine同时使用时,可以考虑换一种选择
- 免费注册的域名.tk
- 关于NSURL
- HR说,这才是合格的简历
- git - Restore locally deleted files with git