Advertisement
193030

2 uravneniq better syntax

Feb 13th, 2022
1,095
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.26 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 Y1_F  (x3&X2_REV&x1) || (x3&x2&X1_REV) || (x2 & X1_REV)
  7. #define Y2_F (X3_REV&X1_REV) || (X3_REV & X2_REV&x1) || (x3&x2&x1)
  8.  
  9. bool matrixResultMax[9][11] = {};
  10.  
  11. using namespace std;
  12.  
  13. bool x1 = 0;
  14. bool x2 = 0;
  15. bool x3 = 0;
  16. bool y1, y2;
  17. bool y1_f[5];
  18. bool y2_f[5];
  19.  
  20.  
  21. int tableX[9][3] = {
  22.     {0,0,0},
  23.     {0,0,1},
  24.     {0,1,0},
  25.     {0,1,1},
  26.     {1,0,0},
  27.     {1,0,1},
  28.     {1,1,0},
  29.     {1,1,1}
  30. };
  31.  
  32. void printTable()
  33. {
  34.     for(int i =0; i<8; i++)
  35.     {
  36.         for(int j =0; j<3;j++)
  37.         {
  38.             cout << tableX[i][j] << " ";
  39.  
  40.         }
  41.         cout << endl;
  42.     }
  43. }
  44.  
  45. void calc()
  46. {
  47.  
  48.     for(int i =0; i<8; i++)
  49.     {
  50.         // -- F0------
  51.         x1 = tableX[i][2];
  52.         x2 = tableX[i][1];
  53.         x3 = tableX[i][0];
  54.         bool y1_f0 = Y1_F;
  55.         bool y2_f0 = Y2_F;
  56.         /-----------------------
  57.  
  58.            
  59.          // F1 ---------------------------------
  60.         #define x2 0
  61.             bool y1_f1 = Y1_F;
  62.             bool y2_f1 = Y2_F;
  63.         #undef x2
  64.         // -------------------------
  65.          
  66.         // F2 ---------------------
  67.         bool y1_f2 = Y1_F;
  68.         #undef X3_REV
  69.         #define X3_REV 0
  70.             bool y2_f2 = Y2_F;
  71.         #undef X3_REV
  72.         #define X3_REV ((x3+1) % 2)
  73.         //------------------------------
  74.  
  75.         // F3 ------------------------
  76.  #define T3_y1  0 || (x3&x2*X1_REV) || (x2 & X1_REV)
  77.             bool y1_f3 = T3_y1;
  78.             bool y2_f3 = Y2_F;
  79.         // --------------------------------------
  80.      
  81.         // F4 -----------------------
  82.         #define T4_y2  1 || (X3_REV & X2_REV & x1) || (x3&x2&x1)
  83.             bool y1_f4 = Y1_F;
  84.             bool y2_f4 = T4_y2;
  85.         // ----------------------------
  86.        
  87.         matrixResultMax[i][0] = y1_f0;
  88.         matrixResultMax[i][1] = y2_f0;
  89.         matrixResultMax[i][2] = y1_f1;
  90.         matrixResultMax[i][3] = y2_f1;
  91.         matrixResultMax[i][4] = y1_f2;
  92.         matrixResultMax[i][5] = y2_f2;
  93.         matrixResultMax[i][6] = y1_f3;
  94.         matrixResultMax[i][7] = y2_f3;
  95.         matrixResultMax[i][8] = y1_f4;
  96.         matrixResultMax[i][9] = y2_f4;
  97.         // cout << x3 << x2 << x1 << "   |" << y1_f0  << " " <<
  98.         //  y2_f0 << " "<< y1_f1 << " " << y2_f1 << " "<< y1_f2 << " " << y2_f2 <<
  99.         //  " "<< y1_f3 << " " << y2_f3 <<
  100.         //  " "<< y1_f4 << " " << y2_f4 <<        endl;
  101.         cout << x3 << x2 << x1 << "   |" << y1_f3 << " " << y2_f3 << endl;
  102.        
  103.     }
  104.  
  105.  
  106. }
  107.  
  108. void printMatrixResult()
  109. {
  110.     for(int i =0; i<=8;i++)
  111.     {
  112.         for(int j =0; j < 10; j++)
  113.         {
  114.             cout << matrixResultMax[i][j] << " ";
  115.         }
  116.         cout << endl;
  117.     }
  118. }
  119.  
  120. void printMatrixResultFormated()
  121. {
  122.     for(int i =0; i<8;i++)
  123.     {
  124.         for(int j =0; j <10;)
  125.         {
  126.             cout << matrixResultMax[i][j] << " ";
  127.             j+=2;
  128.         }
  129.         cout << endl;
  130.       for(int k =1; k <10;)
  131.         {
  132.             cout << matrixResultMax[i][k] << " ";
  133.             k+=2;
  134.         }
  135.                 cout << endl;
  136.             cout << endl;
  137.  
  138.        
  139.     }
  140. }
  141.  
  142.  
  143. int main()
  144. {
  145.     calc();
  146.     printMatrixResult();
  147.     cout << "y1: " << endl;
  148.     printMatrixResultFormated();
  149.  
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement