Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int printArray(int * arr, unsigned sz) {
- for (unsigned i = 0; i < sz; i++) {
- cout << arr[i] << "\t";
- }
- cout << endl;
- return 0;
- }
- void genElemKSet(int * uset, int * set, unsigned sz, int pos, unsigned curr) {
- if (curr == sz) printArray(set, sz);
- else {
- if (curr % pos == 0) {
- set[curr] = 0;
- genElemKSet(uset, set, sz, pos, curr + 1);
- set[curr] = 1;
- genElemKSet(uset, set, sz, pos, curr + 1);
- }
- else {
- set[curr] = 1;
- genElemKSet(uset, set, sz, pos, curr + 1);
- }
- }
- }
- void genElemKSet(int * uset, int * set,unsigned* poslArr,unsigned razmer, unsigned poziciq , unsigned sz, int elem, unsigned curr,unsigned currZaArr);
- int main()
- {
- const unsigned sz = 5;
- int uarr[sz] = { 1, 2, 3, 4, 5 };
- char bitmaskA[] = "10110";
- int subset[sz];
- cout << "Genetate all subsets of the universal set, that have are nechetni mamkamu: " << endl;
- genElemKSet(uarr,subset,sz,2,0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement