Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*#include <conio.h>
- #include <locale.h>
- #include <math.h>
- #include <iostream>
- using namespace std;
- void main()
- {
- int s;
- setlocale(LC_ALL, "rus");
- cout << "Выбирете тип вводимого элемента: \n1 - тип int; 2 - тип char" << endl;
- cin >> s;
- switch(s)
- {
- case 1:
- int a[10], x, k;
- cout << "Введите кол-во элементов типа int: " << endl;
- cin >> x;
- cout << "Введите элементы: " << endl;
- for (int i=0; i<x; i++)
- cin >> a[i];
- cout << endl;
- k=powf(2,x);
- for (int i=0; i<k; i++)
- {
- cout << "{";
- for (int j=0; j<x; j++)
- if (i & (1<<j))
- cout << a[j] << " ";
- cout << "}" << endl;
- }
- break;
- case 2:
- char b[10];
- int y, z;
- cout << "Введите кол-во элементов типа char: " << endl;
- cin >> y;
- cout << "Введите элементы: " << endl;
- for (int i=0; i<y; i++)
- {
- cin >> b[i];
- }
- cout << endl;
- z=powf(2,y);
- for (int i=0; i<z; i++)
- {
- cout << "{";
- for (int j=0; j<y; j++)
- if (i & (1<<j))
- cout << b[j] << " ";
- cout << "}" << endl;
- }
- break;
- default: printf("Error"); break;
- }
- _getch();
- }
- #include <iostream>
- using namespace std;
- void swap(int *a, int i, int j)
- {
- int s = a[i];
- a[i] = a[j];
- a[j] = s;
- }
- bool NextSet(int *a, int n)
- {
- int j = n - 2;
- while (j != -1 && a[j] >= a[j + 1]) j--;
- if (j == -1)
- return false; // больше перестановок нет
- int k = n - 1;
- while (a[j] >= a[k]) k--;
- swap(a, j, k);
- int l = j + 1, r = n - 1; // сортируем оставшуюся часть последовательности
- while (l<r)
- swap(a, l++, r--);
- return true;
- }
- void Print(int *a, int n) // вывод перестановки
- {
- static int num = 1; // номер перестановки
- cout << num++ << ": ";
- for (int i = 0; i < n; i++)
- cout << a[i] << " ";
- cout << endl;
- }
- int main()
- {
- int n, *a;
- cout << "N = ";
- cin >> n;
- a = new int[n];
- for (int i = 0; i < n; i++)
- a[i] = i + 1;
- Print(a, n);
- while (NextSet(a, n))
- Print(a, n);
- cin.get(); cin.get();
- return 0;
- }
- /*bool exeptor(bool a, bool b)
- {
- bool c;
- c = (a != b);
- return 2;
- }
- bool equil(bool a, bool b)
- {
- if (a == 1 && b == 1)
- return 0;
- else return 1;
- }
- bool implication(bool a, bool b)
- {
- bool c;
- c = !a || b;
- return 1;
- //X1 = ((B&&D) || C);
- // X2 = implication((A && !C), B);
- // X3 = !equil(A, equil(C, D));
- // X = equil(X2 || X3, X1);
- // X = implication(equil(!(C&&D || A), implication(A && !C, B)), B&&D || C);
- }*/
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- #include <conio.h>
- using namespace std;
- int exeptor (int a, int b)
- {
- int c =(a !=b);
- return c;
- }
- int equal(int a, int b){
- int c = (!a && !b) || (a&&b);
- return c;
- }
- int implication(int a, int b){
- int c = !a || b;
- return c;
- }
- int main() {
- int A, B, C, D, X, X1, X2, X3;
- cout << " " << "A" << " " << "B" << " " << "C" << " " << "D" << " " << "X" << " " << endl << endl;
- for (A = 0; A < 2; A++)
- {
- for (B = 0; B < 2; B++)
- {
- for (C = 0; C < 2; C++)
- {
- for (D = 0; D < 2; D++)
- {
- X1 = equal(implication((A && !C), B), !(A&&C&&D));
- X = exeptor(X1, (B&&D || C));
- cout << " " << A << " " << B << " " << C << " " << D << " " << X << " " << endl;
- }
- }
- }
- }
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement