A simple algorithm for solving rectangles in the class written in C++