-->
当前位置:首页 > 题库

PROGRAMMING:Solving linear equation with one variable

Luz5年前 (2021-05-10)题库462
Please write a program to solve the unary linear equation $$ax + B = 0 $$.
The formula for solving the equation is as follows:
![ Title. JPG] (~ / f3cc2671-9c7b-4c21-9b82-d88f9c966ac5. JPG)
requirement:
-If $$a = 0 $$, it is a linear equation of one variable.
-If $$a / NEQ 0 $$, then the equation has a unique solution and the solution is output;
-If $$a = 0, B / NEQ 0 $$, then the equation has no solution and "no solution" is output;
-If $$a = 0, B = 0 $$, the equation has infinitely many solutions and outputs "infinitely many solutions".
####Input format
> $$a, b$$
####Output format
> $$x$$
Note: real numbers are output with format qualifier% G.
####Input sample 1
```in
4.5 -3.6
```
####Output sample 1
```out
x = 0.8
```
####Input sample 2
```in
2.8 0
```
####Output sample 2
```out
x = 0
```
####Input sample 3
```in
0 3.6
```
####Output sample 3
```out
unsolvable
```
####Input sample 4
```in
0 0
```
####Output sample 4
```out
Infinitely many solutions
```
Tip: pay attention to the negative zero of real numbers.







answer:If there is no answer, please comment