A
A
Alexander Petrenko2018-04-06 06:02:40
C++ / C#
Alexander Petrenko, 2018-04-06 06:02:40

Solution of class 5 equation in C?

Hello, how can I solve the problem? The user enters a line in which the equation is written (the numbers included in the equations contain up to 4 characters), the output must be an integer x. Number of unknown variables 1 (x).
I would be very grateful.
Example:
4+2x=6 (Answer x = 1)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mercury13, 2018-04-06
@Mercury13

This is a difficult matter. And I would divide it into three overlapping stages.
1. See in the line an equation from one variable. For example, in this form.
2. See what happened as a linear equation.
3. Launch the "Linear Equation" module, which will add similar terms and calculate the answer.

A
Armenian Radio, 2018-04-06
@gbg

Sit down at the keyboard, open the IDE and write-write-write.
If the equation is algebraic and of the first degree, it always has a unique solution.
The method for solving such equations, in the general case, is that:
1) you need to open all the brackets
2) bring similar ones
3) move X to the left side
4) the right side is the desired answer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question