program calklin;
uses
crt;
var
a, b, x: real;
begin
textcolor(red);
gotoxy(10, 5);
write('Вас приветствует калькулятор решать линейные уравнения');
gotoxy(10, 6);
write('Введите а=');
readln(a);
gotoxy(10, 7);
write('Введите b=');
readln(b);
gotoxy(10, 8);
if a = 0
then
begin
gotoxy(10, 9);
textcolor(red);
writeln('Нет корней')
end
else
begin
if a <> 0
then
begin
gotoxy(10, 10);
textcolor(red);
x := (-b / a);
writeln('Уравнение имеет корень и он равен: x =', x, '');
end;
end;
end.
package testStudentCode;
//import java.util.Arrays;
import java.util.Scanner;
public class TestStudentCode {
public static void main(String[] args) {
/* This reads the input provided by user
* using keyboard
*/
Scanner scan = new Scanner(System.in);
System.out.print("a = ?");
// This method reads the number provided using keyboard
double a = scan.nextDouble();
System.out.print("b = ?");
double b = scan.nextDouble();
// Closing Scanner after the use
scan.close();
System.out.println(a + "x + (" + b + ") = 0");
if (a == 0) {
System.out.println("a = 0");
} else {
double x = - b / a;
System.out.println("x = " + x);
}
}
}
Объяснение:
как то так
Надеюсь на лучший ответ!
Программа: 21122
1) Умножь на 4
2) Вычить b
(4-b)*4*4-b-b=28
64-16b-b-b=28
-18b=-36
b=2
ПРОВЕРКА:
(4-2)*4*4-2-2=28
32-2-2=28
28=28