How to have C++ solve the equation for an input value?

前端 未结 4 1548
Happy的楠姐
Happy的楠姐 2021-01-29 08:06

I am stuck trying to figure out a way using C++ to solve a situation where the user inputs a value using cin and then have the computer solve for a way to get the value of cin,

4条回答
  •  北海茫月
    2021-01-29 08:38

    It looks like you think that C++ is going to solve equations for you. It won't. C++ is an imperative style language that is based around the concept of you telling it exactly what to do.

    You will have to figure out how to solve for x and y so that you can make an algorithm. This algorithm is then what you make your program from.

    There exists other languages in which you can in a sense describe what you want and have the compiler or runtime figure out how to get it for you. C++ is not one of them.

    Different ways to solve your particular problem would be to set up an equation system and solving that. Or do brute force approach and iterate through the values of x and y in order to find out which values match.

提交回复
热议问题