private void ButtonPSNF_Click(object sender, RoutedEventArgs e) { try { if (psnfIScalc == false) { PSNF = list_boolean[idSelect].CalculationPSNF(list_boolean[idSelect].boolean_Function_TruthTable_interface, 3); TextBoxContent.Text += "СКНФ для F(N1 = " + list_boolean[idSelect].N1 + ")" + '\n'; TextBoxContent.Text += CommonFunction.OneDimensionalArrOut(PSNF.row_table_name, 4); TextBoxContent.Text += CommonFunction.TwoDimensionalArrOut(PSNF.variable_table, CommonFunction.CalculateArrSize(8, 3, 0, list_boolean[idSelect].boolean_Function_TruthTable_interface), 4); PSNF = list_boolean[idSelect].CalculationPSNF(list_boolean[idSelect].boolean_Function_TruthTable_interface, 4); TextBoxContent.Text += "СКНФ для F(N2 = " + list_boolean[idSelect].N2 + ")" + '\n'; TextBoxContent.Text += CommonFunction.OneDimensionalArrOut(PSNF.row_table_name, 4); TextBoxContent.Text += CommonFunction.TwoDimensionalArrOut(PSNF.variable_table, CommonFunction.CalculateArrSize(8, 4, 0, list_boolean[idSelect].boolean_Function_TruthTable_interface), 4); psnfIScalc = true; } else { MessageBox.Show("Таблица СДНФ уже вычислена!", "Предупреждение"); } } catch { if (TruthTableIScalc == false) { MessageBox.Show("Ошибка, требуется вычислить таблицу истенности!", "Предупеждение"); } else { MessageBox.Show("Ошибка при вычислений таблицы СКНФ!", "Error 7"); } } }
public void SetRow(int[] row_var, TruthTable truthTable, int index_row, int kol_column) // int kol_c for xyz = 8 { for (int n = 0; n <= kol_column; n++) { truthTable.variable_table[n, index_row] = row_var[n]; } }
public void SetRow(char[] row_var, TruthTable truthTable, int index_row, int kol_column) { kol_column++; for (int n = 0; n < kol_column; n++) { truthTable.variable_table[n, index_row] = Convert.ToInt32(row_var[n].ToString()); } kol_column = 0; }
public TruthTable CalculationPDNF(TruthTable truthTable, int index_row) { int kol_column = 8; // kol colomn from function wich 3 vars int index_row_PDNF = 0; int index_row_n2; int size = 0; if (index_row == 3) { index_row_n2 = index_row; } else { index_row_n2 = 3; } string[] buff = { "x", "y", "z", "F" }; TruthTable truthTableCalculation = new TruthTable(); truthTableCalculation.row_table_name = buff; for (int n = 0; n < kol_column; n++) { if (truthTable.variable_table[n, index_row] == 1) { size++; } } truthTableCalculation.variable_table = new int[size, 4]; for (int n = 0; n < kol_column; n++) { if (truthTable.variable_table[n, index_row] == 1) { truthTableCalculation.variable_table[index_row_PDNF, index_row_n2] = truthTable.variable_table[n, index_row]; truthTableCalculation.variable_table[index_row_PDNF, 0] = truthTable.variable_table[n, 0]; truthTableCalculation.variable_table[index_row_PDNF, 1] = truthTable.variable_table[n, 1]; truthTableCalculation.variable_table[index_row_PDNF, 2] = truthTable.variable_table[n, 2]; index_row_PDNF++; } } return(truthTableCalculation); }
public TruthTable CalculationTruthTable(BooleanFunction booleanFunction) { TruthTable truthTable = new TruthTable(); string[] buff = { "x", "y", "z", "F1", "F2" }; truthTable.row_table_name = buff; int[,] buff3 = new int[8, 5]; truthTable.variable_table = buff3; int[] buff2 = new int[] { 0, 0, 0, 0, 1, 1, 1, 1 }; truthTable.SetRow(buff2, truthTable, 0, 7); buff2 = new int[] { 0, 0, 1, 1, 0, 0, 1, 1 }; truthTable.SetRow(buff2, truthTable, 1, 7); buff2 = new int[] { 0, 1, 0, 1, 0, 1, 0, 1 }; truthTable.SetRow(buff2, truthTable, 2, 7); truthTable.SetRow(n1_bool, truthTable, 3, 7); truthTable.SetRow(n2_bool, truthTable, 4, 7); booleanFunction.boolean_Function_TruthTable = truthTable; return(truthTable); }
public static int CalculateArrSize(int kol_column, int index_row, int condition, TruthTable truthTable) // вычисляет рсзмер массива для СКНФ/СДНФ; 1arg - количество строк по 'y'; 2arg - строка с функцией; 3arg - Критерий оченки для СКНФ = 0, для СДНФ = 1; 4arg - Матрица истенности; { int size = 0; for (int n = 0; n < kol_column; n++) { if (truthTable.variable_table[n, index_row] == condition) { size++; } } return(size); }