Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <locale.h>
- using namespace std;
- const int n = 16;
- int main() {
- setlocale(LC_ALL, "Rus");
- bool a[n], b[n], c[n], d[n], rez[n];
- bool pol[n];
- int x = 0, t1, t2, t3, i, k = 0, m = 0;
- int count1 = 0, count = 0, j = 0;
- int temp[10];
- const int p = 3;
- string T0[p], T1[p], tm[p], tl[p], ts[p];
- a[k] = 0; b[k] = 0; c[k] = 0; d[k] = 0;
- for (i = 0; i < p; i++) {
- T0[i] = "-";
- T1[i] = "-";
- tm[i] = "-";
- tl[i] = "-";
- ts[i] = "-";
- }
- //Таблица истинности
- //cout << 'A' << ' ' << 'B' << ' ' << 'C' << ' ' << 'D' << ' ' << 'f' << endl;
- for (int j = 0; j < n - 1; j++) {
- rez[j] = a[k] && d[k] || b[k] && d[k] ||c[k];
- x++;
- t1 = x;
- for (i = 0; i < 4; i++) {
- temp[i] = 0;
- }
- i = 0;
- if (t1 == 1) temp[0] = 1;
- while (t1 >= 2) {
- m++;
- t2 = t1;
- t1 /= 2;
- t3 = t2 - t1 * 2;
- temp[i] = t3;
- i++;
- temp[i] = 1;
- }
- k++;
- d[k] = temp[0];
- c[k] = temp[1];
- b[k] = temp[2];
- a[k] = temp[3];;
- }
- rez[x] = a[k] && d[k] || b[k] && d[k] || c[k];
- /*for (i = 0; i < n; i++) {
- cout << a[i] << ' ' << b[i] << ' ' << c[i] << ' ' << d[i] << ' ' << rez[i];
- cout << endl;
- }
- cout << endl << endl; */
- //T0
- if (rez[0] == 0) T0[0] = "+";
- //T1
- if (rez[n-1] == 1) T1[0] = "+";
- //Монотонность
- for (i = 0; i < n - 1; i++) {
- if (rez[i] > rez[i + 1]) count++;
- }
- if (count == 0) tm[0] = "+";
- //Самодвойственность
- count = 0;
- j = n - 1;
- for (i = 0; i < (n / 2); i++) {
- if (rez[i] == rez[j]) count++;
- j--;
- }
- if (count == 0) ts[0] = "+";
- //Линейность
- i = n;
- pol[0] = 0;
- j = 0;
- for (int m = 0; m < n; m++) {
- while (j != i - 1) {
- if ((rez[j] == 0 && rez[j + 1] == 1) || (rez[j] == 1 && rez[j + 1] == 0)) {
- rez[j] = 1;
- }
- else rez[j] = 0;
- // cout << rez[j];
- j++;
- }
- // cout << endl;
- i--;
- pol[m+1] = rez[0];
- j = 0;
- }
- count = 0;
- for (i = 0; i < n; i++) {
- if (pol[i] == 1) {
- if (a[i] == 1) count1++;
- if (b[i] == 1) count1++;
- if (c[i] == 1) count1++;
- if (d[i] == 1) count1++;
- }
- if (count1 > count) count = count1;
- count1 = 0;
- }
- // cout << count;
- if (count <= 1) tl[0] = "+";
- // cout << endl;
- //Вывод итоговых значений
- /* cout << T0 << ' ' << T1 << ' ' << tm << ' ' << tl << ' ' << ts;
- cout << endl;
- if (T0 == "-" && T1 == "-" && tm == "-" && ts == "-" && tl == "-") cout << "Функционально полная";
- else cout << "Функционально не полная";
- cout << endl << endl; */
- x = 0; k = 0; m = 0;
- count1 = 0; count = 0; j = 0;
- x = 0;
- // cout << 'A' << ' ' << 'B' << ' ' << 'C' << ' ' << 'D' << ' ' << 'f' << endl;
- for (int j = 0; j < n - 1; j++) {
- rez[j] = a[k] && b[k] && !c[k] || !b[k] && c[k] && d[k] || !a[k] && d[k];
- x++;
- t1 = x;
- for (i = 0; i < 4; i++) {
- temp[i] = 0;
- }
- i = 0;
- if (t1 == 1) temp[0] = 1;
- while (t1 >= 2) {
- m++;
- t2 = t1;
- t1 /= 2;
- t3 = t2 - t1 * 2;
- temp[i] = t3;
- i++;
- temp[i] = 1;
- }
- k++;
- d[k] = temp[0];
- c[k] = temp[1];
- b[k] = temp[2];
- a[k] = temp[3];;
- }
- rez[x] = a[k] && b[k] && !c[k] || !b[k] && c[k] && d[k] || !a[k] && d[k];
- /*for (i = 0; i < n; i++) {
- cout << a[i] << ' ' << b[i] << ' ' << c[i] << ' ' << d[i] << ' ' << rez[i];
- cout << endl;
- }
- cout << endl << endl;*/
- //T0
- if (rez[0] == 0) T0[1] = "+";
- //T1
- if (rez[n - 1] == 1) T1[1] = "+";
- //Монотонность
- for (i = 0; i < n - 1; i++) {
- if (rez[i] > rez[i + 1]) count++;
- }
- if (count == 0) tm[1] = "+";
- //Самодвойственность
- count = 0;
- j = n - 1;
- for (i = 0; i < (n / 2); i++) {
- if (rez[i] == rez[j]) count++;
- j--;
- }
- if (count == 0) ts[1] = "+";
- //Линейность
- i = n;
- pol[0] = 0;
- j = 0;
- for (int m = 0; m < n; m++) {
- while (j != i - 1) {
- if ((rez[j] == 0 && rez[j + 1] == 1) || (rez[j] == 1 && rez[j + 1] == 0)) {
- rez[j] = 1;
- }
- else rez[j] = 0;
- // cout << rez[j];
- j++;
- }
- // cout << endl;
- i--;
- pol[m + 1] = rez[0];
- j = 0;
- }
- count = 0;
- for (i = 0; i < n; i++) {
- if (pol[i] == 1) {
- if (a[i] == 1) count1++;
- if (b[i] == 1) count1++;
- if (c[i] == 1) count1++;
- if (d[i] == 1) count1++;
- }
- if (count1 > count) count = count1;
- count1 = 0;
- }
- //cout << count;
- if (count <= 1) tl[1] = "+";
- //cout << endl;
- //Вывод итоговых значений
- /*cout << T0 << ' ' << T1 << ' ' << tm << ' ' << tl << ' ' << ts;
- cout << endl;
- if (T0 == "-" && T1 == "-" && tm == "-" && ts == "-" && tl == "-") cout << "Функционально полная";
- else cout << "Функционально не полная";
- cout << endl;*/
- x = 0; k = 0; m = 0;
- count1 = 0; count = 0; j = 0;
- x = 0;
- // cout << 'A' << ' ' << 'B' << ' ' << 'C' << ' ' << 'D' << ' ' << 'f' << endl;
- for (int j = 0; j < n - 1; j++) {
- rez[j] = (a[k] || !b[k] || !c[k]) && (b[k] || c[k] || !d[k]) && (!b[k] || !d[k]);
- x++;
- t1 = x;
- for (i = 0; i < 4; i++) {
- temp[i] = 0;
- }
- i = 0;
- if (t1 == 1) temp[0] = 1;
- while (t1 >= 2) {
- m++;
- t2 = t1;
- t1 /= 2;
- t3 = t2 - t1 * 2;
- temp[i] = t3;
- i++;
- temp[i] = 1;
- }
- k++;
- d[k] = temp[0];
- c[k] = temp[1];
- b[k] = temp[2];
- a[k] = temp[3];;
- }
- rez[x] = (a[k] || !b[k] || !c[k]) && (b[k] || c[k] || !d[k]) && (!b[k] || !d[k]);
- /*for (i = 0; i < n; i++) {
- cout << a[i] << ' ' << b[i] << ' ' << c[i] << ' ' << d[i] << ' ' << rez[i];
- cout << endl;
- }
- cout << endl << endl;*/
- //T0
- if (rez[0] == 0) T0[2] = "+";
- //T1
- if (rez[n - 1] == 1) T1[2] = "+";
- //Монотонность
- for (i = 0; i < n - 1; i++) {
- if (rez[i] > rez[i + 1]) count++;
- }
- if (count == 0) tm[2] = "+";
- //Самодвойственность
- count = 0;
- j = n - 1;
- for (i = 0; i < (n / 2); i++) {
- if (rez[i] == rez[j]) count++;
- j--;
- }
- if (count == 0) ts[2] = "+";
- //Линейность
- i = n;
- pol[0] = 0;
- j = 0;
- for (int m = 0; m < n; m++) {
- while (j != i - 1) {
- if ((rez[j] == 0 && rez[j + 1] == 1) || (rez[j] == 1 && rez[j + 1] == 0)) {
- rez[j] = 1;
- }
- else rez[j] = 0;
- // cout << rez[j];
- j++;
- }
- // cout << endl;
- i--;
- pol[m + 1] = rez[0];
- j = 0;
- }
- count = 0;
- for (i = 0; i < n; i++) {
- if (pol[i] == 1) {
- if (a[i] == 1) count1++;
- if (b[i] == 1) count1++;
- if (c[i] == 1) count1++;
- if (d[i] == 1) count1++;
- }
- if (count1 > count) count = count1;
- count1 = 0;
- }
- //cout << count;
- if (count <= 1) tl[2] = "+";
- // cout << endl;
- //Вывод итоговых значений
- /*cout << T0 << ' ' << T1 << ' ' << tm << ' ' << tl << ' ' << ts;
- cout << endl;
- if (T0 == "-" && T1 == "-" && tm == "-" && ts == "-" && tl == "-") cout << "Функционально полная";
- else cout << "Функционально не полная";
- cout << endl;*/
- int countT0=0, countT1=0, counttm=0, counttl=0, countts=0;
- for (i = 0; i < p; i++) {
- cout << T0[i];
- if (T0[i] == "-") countT0++;
- cout << T1[i];
- if (T1[i] == "-") countT1++;
- cout << tm[i];
- if (tm[i] == "-") counttm++;
- cout << tl[i];
- if (tl[i] == "-") counttl++;
- cout << ts[i] << endl;
- if (ts[i] == "-") countts++;
- }
- if (countT0 >= 1 && countT1 >= 1 && counttm >= 1 && counttl >= 1 && countts >= 1)
- cout << "система функциональна полная";
- else cout << "система функционально не полная";
- cout << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement