I written a Truth Table Generator using C/C++; however, I am not yet familiar with C++ concepts, especially C++11 or greater. I'll like to rewrite it using just C++. At lease C++11.

1 answer below »
I written a Truth Table Generator using C/C++; however, I am not yet familiar with C++ concepts, especially C++11 or greater. I'll like to rewrite it using just C++. At lease C++11.
Answered 4 days AfterJan 14, 2021

Answer To: I written a Truth Table Generator using C/C++; however, I am not yet familiar with C++ concepts,...

Neha answered on Jan 17 2021
138 Votes
#include
    #include
    #include
    #include
    #include
    #define MAX_LINE 256
    using namespace std;
    vector column;
    vector
formula_vector;
    vector variables;
    vector > rows;
    vectornull_vector;
    int num_variables = 0;
    bool findCharString (string myString, string toFindChar);
    int findVariable (string variable);
    int findClosingParent (int start );
    vector compute (string operation, vectorv1, vector v2);
    int findVariable (string variable)
    {
        for(int i = 0; i < num_variables ; i++)
        {
            if (variable.compare(variables[i]) == 0)
                return i;
        }
    }
    bool findCharString (string myString, string toFindChar)
    {
        size_t found;
        found = myString.find_first_of(toFindChar);
        if (found == string::npos)
            return false;
        else
            return true;
    }
    int findClosingParent (int start )
    {
        int open = 0;
        int close_p = 0;
        int counter = start;
        while (counter        {
            if (formula_vector[counter].compare(")") == 0)
                close_p++;
            else if (formula_vector[counter].compare("(") == 0)
                open++;
            if (open == close_p)
                return counter;
            counter++;
        }
    }
    void createTruthTables_2(int number_variables)
    {
        int num_2_fill = 0;
        rows.resize(number_variables);
        column. resize (pow(2.0,number_variables));
        rows.assign(number_variables,column);
        for (int i=0; i            num_2_fill = pow(2.0, (number_variables -1)-i);
            for (int j = 0; j                for (int k = j; k                    rows[i][k] = true;
            }
        }
                for(int i=0;i                    cout<                 for (int j=0;j                     cout <                     cout << endl;
        }
    }
    vector...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here