Advertisement
193030

2 uravneniq matrici

Feb 13th, 2022
819
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.17 KB | None | 0 0
  1. #include <iostream>
  2. #define X1_REV  ((x1+1) % 2)
  3. #define X2_REV ((x2+1) % 2)
  4. #define X3_REV ((x3+1) % 2)
  5.  
  6. #define X1 x1
  7. #define X2 x2
  8. #define X3 x3
  9.  
  10. #define Y1_F  (x1&x2) || (X1_REV&X2_REV) || (X1&X2&X3) || (X1_REV&X2_REV&X3_REV)
  11. #define Y2_F (x1&x2&x3)
  12.  
  13. // --- 1
  14. #define Y1_F1  (1&x2) || (X1_REV&X2_REV) || (X1&X2&X3) || (X1_REV&X2_REV&X3_REV)
  15. // ---- end of 1
  16.  
  17.  
  18. /// ----2
  19. #define Y2_F2 (x1&x2&1)
  20. // --- end of 2
  21.  
  22. // ----- 3
  23. #define Y1_F3  (x1&x2) || (X1_REV&X2_REV) || (X1&X2&X3) || (X1_REV&X2_REV&0)
  24.  
  25.  
  26. // --- 4  
  27. #define Y1_F4  (x1&x2) || (X1_REV&X2_REV) || (X1&X2&X3) || (1)
  28.  
  29.  
  30.  
  31.  
  32. bool matrixResultMax[9][11] = {};
  33.  
  34. using namespace std;
  35.  
  36. bool x1 = 0;
  37. bool x2 = 0;
  38. bool x3 = 0;
  39. bool y1, y2;
  40. bool y1_f[5];
  41. bool y2_f[5];
  42.  
  43.  
  44. int tableX[9][3] = {
  45.     {0,0,0},
  46.     {0,0,1},
  47.     {0,1,0},
  48.     {0,1,1},
  49.     {1,0,0},
  50.     {1,0,1},
  51.     {1,1,0},
  52.     {1,1,1}
  53. };
  54.  
  55.  
  56.  
  57.  
  58. void new_method()
  59. {
  60.    
  61.         for(int i =0; i<8; i++)
  62.         {
  63.             x1 = tableX[i][2];
  64.             x2 = tableX[i][1];
  65.             x3 = tableX[i][0];
  66.  
  67.             bool y1_f0 = Y1_F;
  68.             bool y2_f0 = Y2_F;
  69.             matrixResultMax[i][0] = y1_f0;
  70.             matrixResultMax[i][1] = y2_f0;
  71.            
  72.             bool y1_f1 = Y1_F;
  73.             bool y2_f1 = Y2_F;
  74.             matrixResultMax[i][2] = Y1_F1;
  75.             matrixResultMax[i][3] = y2_f1;
  76.            
  77.             bool y1_f2 = Y1_F1;
  78.             bool y2_f2 = Y2_F;
  79.             matrixResultMax[i][4] = y1_f2;
  80.             matrixResultMax[i][5] = Y2_F2;
  81.            
  82.             bool y1_f3 = Y1_F;
  83.             bool y2_f3 = Y2_F;
  84.             matrixResultMax[i][6] = Y1_F3;
  85.             matrixResultMax[i][7] = y2_f3;
  86.            
  87.             bool y1_f4 = Y1_F;;
  88.             bool y2_f4 = Y2_F;
  89.             matrixResultMax[i][8] = Y1_F4;
  90.             matrixResultMax[i][9] = y2_f4;
  91.  
  92.  
  93.         }
  94.    
  95.    
  96.    
  97. }
  98.  
  99. void calc()
  100. {
  101.  
  102.     for(int i =0; i<8; i++)
  103.     {
  104.         x1 = tableX[i][2];
  105.         x2 = tableX[i][1];
  106.         x3 = tableX[i][0];
  107.         bool y1_f0 = Y1_F;
  108.         bool y2_f0 = Y2_F;
  109.  
  110.  
  111.            
  112.            
  113.         #define x2 0
  114.             bool y1_f1 = Y1_F;
  115.             bool y2_f1 = Y2_F;
  116.         #undef x2
  117.        
  118.          
  119.  
  120.         bool y1_f2 = Y1_F;
  121.         #undef X3_REV
  122.         #define X3_REV 0
  123.             bool y2_f2 = Y2_F;
  124.         #undef X3_REV
  125.         #define X3_REV ((x3+1) % 2)
  126.  
  127.  #define T3_y1  0 || (x3&x2*X1_REV) || (x2 & X1_REV)
  128.             bool y1_f3 = T3_y1;
  129.             bool y2_f3 = Y2_F;
  130.  
  131.      
  132.  
  133.         #define T4_y2  1 || (X3_REV & X2_REV & x1) || (x3&x2&x1)
  134.             bool y1_f4 = Y1_F;
  135.             bool y2_f4 = T4_y2;
  136.  
  137.         matrixResultMax[i][0] = y1_f0;
  138.         matrixResultMax[i][1] = y2_f0;
  139.         matrixResultMax[i][2] = y1_f1;
  140.         matrixResultMax[i][3] = y2_f1;
  141.         matrixResultMax[i][4] = y1_f2;
  142.         matrixResultMax[i][5] = y2_f2;
  143.         matrixResultMax[i][6] = y1_f3;
  144.         matrixResultMax[i][7] = y2_f3;
  145.         matrixResultMax[i][8] = y1_f4;
  146.         matrixResultMax[i][9] = y2_f4;
  147.         // cout << x3 << x2 << x1 << "   |" << y1_f0  << " " <<
  148.         //  y2_f0 << " "<< y1_f1 << " " << y2_f1 << " "<< y1_f2 << " " << y2_f2 <<
  149.         //  " "<< y1_f3 << " " << y2_f3 <<
  150.         //  " "<< y1_f4 << " " << y2_f4 <<        endl;
  151.         cout << x3 << x2 << x1 << "   |" << y1_f3 << " " << y2_f3 << endl;
  152.        
  153.     }
  154.  
  155.  
  156. }
  157.  
  158. void printMatrixResult()
  159. {
  160.     for(int i =0; i<=8;i++)
  161.     {
  162.         for(int j =0; j < 10; j++)
  163.         {
  164.             cout << matrixResultMax[i][j] << " ";
  165.         }
  166.         cout << endl;
  167.     }
  168. }
  169.  
  170. void printMatrixResultFormated()
  171. {
  172.     cout << "Nachalo" << endl;
  173.     for(int i =0; i<8;i++)
  174.     {
  175.         for(int j =0; j <10;)
  176.         {
  177.             cout << matrixResultMax[i][j] << " ";
  178.             j+=2;
  179.         }
  180.         cout << endl;
  181.       for(int k =1; k <10;)
  182.         {
  183.             cout << matrixResultMax[i][k] << " ";
  184.             k+=2;
  185.         }
  186.                 cout << endl;
  187.             cout << endl;
  188.  
  189.        
  190.     }
  191.         cout << "krai" << endl;
  192.  
  193. }
  194.  
  195.  
  196. int main()
  197. {
  198.  
  199.     new_method();
  200.     printMatrixResult();
  201.     printMatrixResultFormated();
  202.  
  203. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement