Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.01 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. using namespace std;
  4. const int n = 16;
  5. int main() {
  6.     bool a[n], b[n], c[n], d[n], rez[n];
  7.     bool pol[n];
  8.     int x = 0, t1, t2, t3, i, k = 0, m = 0;
  9.     int count1 =0, count=0, j = 0;
  10.     int temp[10];
  11.     int T0=0, T1=0, tm=0, tl=0, ts=0;
  12.     a[k] = 0; b[k] = 0; c[k] = 0; d[k] = 0;
  13.     cout << 'A' << ' ' << 'B' << ' ' << 'C' << ' ' << 'D' << ' ' << 'f' << endl;
  14.     for (int j = 0; j < n - 1; j++) {
  15.         rez[j] = a[k] && b[k] || !c[k] || !d[k];
  16.         x++;
  17.         t1 = x;
  18.         for (i = 0; i < 4; i++) {
  19.             temp[i] = 0;
  20.         }
  21.         i = 0;
  22.         if (t1 == 1) temp[0] = 1;
  23.         while (t1 >= 2) {
  24.             m++;
  25.             t2 = t1;
  26.             t1 /= 2;
  27.             t3 = t2 - t1 * 2;
  28.             temp[i] = t3;
  29.             i++;
  30.             temp[i] = 1;
  31.         }
  32.         k++;
  33.         d[k] = temp[0];
  34.         c[k] = temp[1];
  35.         b[k] = temp[2];
  36.         a[k] = temp[3];;
  37.     }
  38.     rez[x] = rez[j] = a[k] && b[k] || !c[k] && !d[k];
  39.     for (i = 0; i < n; i++) {
  40.         cout << a[i] << ' ' << b[i] << ' ' << c[i] << ' ' << d[i] << ' ' << rez[i];
  41.         cout << endl;
  42.     }
  43.     cout << endl << endl;
  44.     //T0
  45.     if (rez[0] == 0) T0 = 1;
  46.     //T1
  47.     if (rez[15] == 1) T1 = 1;
  48.     //Монотонность
  49.     for (i = 0; i < n-1; i++) {
  50.         if (rez[i] < rez[i + 1]) count++;
  51.     }
  52.     if (count == 0) tm = 1;
  53.     //Линейность
  54.     i = n;
  55.     for (int m = 0; m < n; m++) {
  56.         while (j != i-1) {
  57.             if ((rez[j] == 0 && rez[j + 1] == 1) || (rez[j] == 1 && rez[j + 1] == 0)) {
  58.                 rez[j] = 1;
  59.             }
  60.             else rez[j] = 0;
  61.             cout << rez[j];
  62.             j++;
  63.         }
  64.         cout << endl;
  65.         i--;
  66.         pol[m] = rez[0];
  67.         j = 0;
  68.     }
  69.     count = 0;
  70.     for (i = 0; i < n; i++) {
  71.         if (pol[i] == 1) {
  72.             if (a[i] == 1) count1++;
  73.             if (b[i] == 1) count1++;
  74.             if (c[i] == 1) count1++;
  75.             if (d[i] == 1) count1++;
  76.         }
  77.         if (count1 > count) count = count1;
  78.         count1 = 0;
  79.     }
  80.     cout << count;
  81.  
  82.     if (count <= 1) tl = 1;
  83.     cout << endl;
  84.     //Самодвойственность
  85.     j = n-1;
  86.     for (i = 0; i < n / 2; i++) {
  87.         if (rez[i] == rez[j]) count++;
  88.     }
  89.     if (count == 0) ts = 1;
  90.     cout << T0 << ' ' << T1 << ' ' << tm << ' ' << tl << ' ' << ts;
  91.     cout << endl;
  92.     return 0;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement