mardi 11 mai 2021

Develop a class that finds how to calculate using division) with the C ++ programming language [closed]

For an integer specified as the target, 6 other integers and four operations (addition, subtraction, multiplication and Develop a class that finds out how to calculate using partition with the C ++ programming language.

As an example, if the target number is 302 and the given numbers are 2, 3, 7, 10, 25, and 50, your class would say "(((2 + 10) * 3) * 7) +50)" Or a different equivalent solution should generate as std :: string.

********************************************************************* // NameSurname.hpp #include "INumberSearch.h" namespace Name Surname { class NumberSearch: public INumberSearch { public: … // Number to reach (302) void SetTargetNumber (const int value) ( // TODO } // Accept numbers as a space separated values: “2 3 7 10 25 50” void SetInputNumbers (const std :: string & values) ( // TODO } // Return result as a string ready to evaluate: “(((2 + 10) * 3) * 7) +50)” const std :: string & GetSolution () ( // TODO } … }; } // namespace NameSurname


The definition of the specified interface class is as follows: class INumberSearch { virtual ~ INumberSearch () {} virtual void SetTargetNumber (const int value) = 0; virtual void SetInputNumbers (const std :: string & values) = 0; virtual const std :: string & GetSolution () = 0; };

Conditions and criteria: [1] Only the .hpp file containing the solution class should be passed. Other additional class definitions that may be needed, It can be done in the same file in user namespace. [2] With modern C ++ (C ++ 11 or C ++ 14) without using an external class library (Qt, Boost, etc.) will be developed. [3] The user class will be accessed by using the interface class in the verifications to be made. [4] In the result value showing the calculations, the order of operation will not be considered, whether the solution is provided or not will be checked. If more than one solution is found, it is sufficient to return to the first solution. [5] In order to ignore the operator priorities, all operations in the solution are should be grouped. [6] The results of the division between integers should only be used in the solution if they are integers. [7] Input numbers must be used once during calculation; all numbers must be used is not

Can you help with the solution of the problem? I would like to thanks a lot in advance for your helping and taking time.

Aucun commentaire:

Enregistrer un commentaire