Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.58 KB | None | 0 0
  1. #include <iostream>
  2. #include "sets.h"
  3.  
  4. const size_t u_size = 10;
  5. const bool U[u_size] = { 1,1,1,1,1,1,1,1,1,1 };
  6. using namespace std;
  7. using namespace bset;
  8. void f(bool A[], bool B[], bool C[], size_t n, size_t m, size_t k, bool res[], size_t* r,const bool st[]);
  9. void wr_row(const bool A[]);
  10. int main()
  11. {
  12.     setlocale(LC_ALL, "rus");
  13.     bool empty_set[u_size];
  14.     size_t size = u_size;
  15.     addition(U, empty_set,&size, u_size);
  16.  
  17.     bool A[u_size] = { 0,1,0,0,0,0,0,0,1,1 };
  18.     bool B[u_size] = { 1,1,0,0,0,0,0,1,1,1 };
  19.     bool C[u_size] = { 1,0,1,0,0,1,1,0,0,0 };
  20.     size_t m, n, k;
  21.     n = 3;
  22.     m = 5;
  23.     k = 4;
  24.    
  25.     bool empty_f[u_size];
  26.     bool U_f[u_size];
  27.     size_t ef_size, uf_size;
  28.  
  29.     f(A, B, C, n, m, k, empty_f, &ef_size,empty_set);
  30.     f(A, B, C, n, m, k, U_f, &uf_size, U);
  31.  
  32.     wr_row(empty_f);
  33.     cout << endl;
  34.     wr_row(U_f);
  35.     system("pause");
  36.     return 0;
  37. }
  38.  
  39. void f(bool A[], bool B[], bool C[], size_t n, size_t m, size_t k, bool res[], size_t* r,const bool st[])
  40. {
  41.     bool buf1[u_size];
  42.     bool buf2[u_size];
  43.     size_t b1_size = 0, b2_size = 0;
  44.  
  45.     union_set(A, st, buf1, &b1_size,u_size);
  46.     difference(st,B, buf2, &b2_size, u_size);
  47.     traversal(buf1, buf2, res, r, u_size);
  48.     union_set(C, res, res, r, u_size);
  49.  
  50.     addition(st, buf1, &b1_size, u_size);
  51.     traversal(A, buf1, buf1, &b1_size, u_size);
  52.     difference(C, st, buf2, &b2_size, u_size);
  53.     sym_difference(buf1, buf2, buf1, &b1_size, u_size);
  54.  
  55.     sym_difference(res, buf1, res, r, u_size);
  56. }
  57. void wr_row(const bool A[])
  58. {
  59.     cout << "Элементы множества: ";
  60.     for (int i = 0; i < u_size; i++)
  61.         if (A[i]) cout << i+1 << " ";
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement