iamantony / CppNotes

My notes about C++
MIT License
1 stars 3 forks source link

Task: calc math expression Ax^a + Bx^b + ... #12

Open iamantony opened 8 years ago

iamantony commented 8 years ago

Coefficients and exponents can be any positive or negatice real number. Input - string. X - some number(s).

class Term
{
public:
    double coeff;
    double exp;
    double val;
    double calc();
}

void calc(string expr)
{
    std::vector<Term> elements = parse(expr);
    double sum = 0.0;
    for (i : elements)
    {
        sum + elements[i].calc();
    }
}