A one-dimensional array of the string type, among others, stores the mathematical formula for the center line of a trapezium of the form: "m = (a + b) / 2". Also, there is a one-dimensional array of type string, in which values are stored, with which we must determine whether these values are enough for us to calculate an expression from the previous array or not, for example: "a", "b". That is, roughly speaking, to check whether "m" is calculated using only "a" and "b", and not using "a", "b" and "c".
1 answer
You need a parser formula anyway.
How to write it is described here and here . By parsing the string, you get either an error (and therefore, the string does not contain a formula) or a syntax tree. By going around it, you can find a list of variable names.
Further it is trivial: having the list of names, you are convinced that all of them are found in the list of values. In fact, by parsing the formula, you can even calculate the result, depending on the values of the parameters.
(Yes, your task is actually very difficult. A parser is not a trivial thing.)
|
m = a - a + b, is it necessary to determine that onlybsufficient? If so, the task becomes much more difficult. - VladD