Advertisement
Guest User

laba1

a guest
Feb 20th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. bool get(int v, int i) {
  8. return (v & (1 << i));
  9. }
  10.  
  11. struct bin_vec {
  12. int val = 0;
  13. int operator [] (int i) {
  14. return get(val, i);
  15. }
  16. int get_weight() {
  17. int w = 0;
  18. for(int i = 0; i < 7; i++)
  19. w += get(val, i);
  20. return w;
  21. }
  22. };
  23.  
  24.  
  25. vector<int> val;
  26.  
  27.  
  28.  
  29. int process(bin_vec x) {
  30. int y = 0;
  31. y ^= (1 << 6) & (x[1] & x[2] ^ x[0] & x[1] & x[3] ^ x[0] & x[4] ^ x[1] & x[5] ^ x[3] & x[5] ^ x[6] ^ x[0] & x[1] & x[6] ^ x[2] & x[3] & x[6] ^ x[1] & x[4] & x[6] ^ x[0] & x[5] & x[6]);
  32. y ^= (1 << 5) & (x[2] ^ x[0] & x[2] ^ x[0] & x[3] ^ x[1] & x[2] & x[3] ^ x[0] & x[2] & x[4] ^ x[0] & x[5] ^ x[2] & x[5] ^ x[4] & x[5] ^ x[1] & x[6] ^ x[1] & x[2] & x[6] ^ x[0] & x[3] & x[6] ^ x[3] & x[4] & x[6] ^ x[2] & x[5] & x[6] ^ 1);
  33. y ^= (1 << 4) & (x[0] & x[2] ^ x[3] ^ x[1] & x[3] ^ x[1] & x[4] ^ x[0] & x[1] & x[4] ^ x[2] & x[3] & x[4] ^ x[0] & x[5] ^ x[1] & x[3] & x[5] ^ x[0] & x[4] & x[5] ^ x[1] & x[6] ^ x[3] & x[6] ^ x[0] & x[3] & x[6] ^ x[5] & x[6] ^ 1);
  34. y ^= (1 << 3) & (x[1] ^ x[0] & x[1] & x[2] ^ x[1] & x[4] ^ x[3] & x[4] ^ x[0] & x[5] ^ x[0] & x[1] & x[5] ^ x[2] & x[3] & x[5] ^ x[1] & x[4] & x[5] ^ x[2] & x[6] ^ x[1] & x[3] & x[6]);
  35. y ^= (1 << 2) & (x[0] & x[1] ^ x[0] & x[4] ^ x[2] & x[4] ^ x[5] ^ x[1] & x[2] & x[5] ^ x[0] & x[3] & x[5] ^ x[6] ^ x[0] & x[2] ^ x[6] ^ x[3] & x[6] ^ x[4] & x[5] & x[6] ^ 1);
  36. y ^= (1 << 1) & (x[0] & x[1] ^ x[0] & x[4] ^ x[2] & x[4] ^ x[5] ^ x[1] & x[2] & x[5] ^ x[0] & x[3] & x[5] ^ x[6] ^ x[0] & x[2] & x[6] ^ x[3] & x[6] ^ x[4] & x[5] & x[6] ^ 1);
  37. y ^= (1 << 0) & (x[1] & x[3] ^ x[4] ^ x[0] & x[1] & x[4] ^ x[5] ^ x[2] & x[5] ^ x[3] & x[4] & x[5] ^ x[6] ^ x[0] & x[6] ^ x[1] & x[6] ^ x[3] & x[6] ^ x[2] ^ x[4] & x[6] ^ x[1] & x[5] & x[6] ^ x[4] & x[5] & x[6]);
  38. return y;
  39. }
  40.  
  41. int main()
  42. {
  43. for (int i = 0; i < (1 << 7); i++) {
  44. val.push_back(process(i));
  45. }
  46. for (int v: val)
  47. cout << v << endl;
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement