Quảng cáo
6 câu trả lời 577
Uses crt;
Var a,b,c,d,x,x1,x2:real;
Begin
Write('Nhap he so a=');readln(a);
Write('Nhap he so b=');readln(b);
Write('Nhap he so c=');readln(c);
If a=0 then
If b=0 then
If c=0 then
Writeln('Phuong trinh co vo so nghiem')
Else
Writeln('Phuong trinh vo nghiem')
Else
Writeln('Phuong trinh co mot nghiem: x=',-c/b:4:2)
Else
Begin
d:=b*b-4*a*c;
If d=0 then
Writeln('Phuong trinh co nghiem kep: x=',-b/(2*a):4:2)
Else
If d<0 then
Writeln('Phuong trinh vo nghiem')
Else
Begin
x1:= (-b+sqrt(d))/(2*a);
x2:= (-b-sqrt(d))/(2*a);
Write('Phuong trinh co hai nghiem: ‘);
Writeln(‘ x1=',x1:4:2,' va x2=',x2:4:2);
End;
End;
Readln;
End.
Uses crt;
Var a,b,c,d,x,x1,x2:real;
Begin
Write('Nhap he so a=');readln(a);
Write('Nhap he so b=');readln(b);
Write('Nhap he so c=');readln(c);
If a=0 then
If b=0 then
If c=0 then
Writeln('Phuong trinh co vo so nghiem')
Else
Writeln('Phuong trinh vo nghiem')
Else
Writeln('Phuong trinh co mot nghiem: x=',-c/b:4:2)
Else
Begin
d:=b*b-4*a*c;
If d=0 then
Writeln('Phuong trinh co nghiem kep: x=',-b/(2*a):4:2)
Else
If d<0 then
Writeln('Phuong trinh vo nghiem')
Else
Begin
x1:= (-b+sqrt(d))/(2*a);
x2:= (-b-sqrt(d))/(2*a);
Write('Phuong trinh co hai nghiem: ‘);
Writeln(‘ x1=',x1:4:2,' va x2=',x2:4:2);
End;
End;
Readln;
End.
Uses crt;
Var a,b,c,d,x,x1,x2:real;
Begin
Write('Nhap he so a=');readln(a);
Write('Nhap he so b=');readln(b);
Write('Nhap he so c=');readln(c);
If a=0 then
If b=0 then
If c=0 then
Writeln('Phuong trinh co vo so nghiem')
Else
Writeln('Phuong trinh vo nghiem')
Else
Writeln('Phuong trinh co mot nghiem: x=',-c/b:4:2)
Else
Begin
d:=b*b-4*a*c;
If d=0 then
Writeln('Phuong trinh co nghiem kep: x=',-b/(2*a):4:2)
Else
If d<0 then
Writeln('Phuong trinh vo nghiem')
Else
Begin
x1:= (-b+sqrt(d))/(2*a);
x2:= (-b-sqrt(d))/(2*a);
Write('Phuong trinh co hai nghiem: ‘);
Writeln(‘ x1=',x1:4:2,' va x2=',x2:4:2);
End;
Readln;
End.
Uses crt;
Var a,b,c,d,x,x1,x2:real;
Begin
Write('Nhap he so a=');readln(a);
Write('Nhap he so b=');readln(b);
Write('Nhap he so c=');readln(c);
If a=0 then
If b=0 then
If c=0 then
Writeln('Phuong trinh co vo so nghiem')
Else
Writeln('Phuong trinh vo nghiem')
Else
Writeln('Phuong trinh co mot nghiem: x=',-c/b:4:2)
Else
Begin
d:=b*b-4*a*c;
If d=0 then
Writeln('Phuong trinh co nghiem kep: x=',-b/(2*a):4:2)
Else
If d<0 then
Writeln('Phuong trinh vo nghiem')
Else
Begin
x1:= (-b+sqrt(d))/(2*a);
x2:= (-b-sqrt(d))/(2*a);
Write('Phuong trinh co hai nghiem: ‘);
Writeln(‘ x1=',x1:4:2,' va x2=',x2:4:2);
End;
End;
Readln;
def ptb2():
a = int(input(' a = '))
b = int(input(' b = '))
c = int(input(' c = '))
delta = b*b - 4*a*c
import math
if delta > 0:
print('Phương trình có 2 nghiệm phân biệt :')
print('x1 = ', (-b - math.sqrt(delta)) / 2*a )
print('x2 = ', (-b + math.sqrt(delta)) / 2*a )
elif delta == 0:
print(' Phương trình có nghiệm kép ', -b/2*a)
else:
print(' Phương trình vô nghiện')
ptb2()
#include <stdio.h>
#include <math.h>
int main() {
float a, b, c, delta, x1, x2;
printf("Nhap he so a: ");
scanf("%f", &a);
printf("Nhap he so b: ");
scanf("%f", &b);
printf("Nhap he so c: ");
scanf("%f", &c);
delta = b * b - 4 * a * c;
if (delta > 0) {
x1 = (-b + sqrt(delta)) / (2 * a);
x2 = (-b - sqrt(delta)) / (2 * a);
printf("Phuong trinh co hai nghiem phan biet:\n");
printf("x1 = %f\n", x1);
printf("x2 = %f\n", x2);
} else if (delta == 0) {
x1 = -b / (2 * a);
printf("Phuong trinh co nghiem kep:\n");
printf("x1 = x2 = %f\n", x1);
} else {
printf("Phuong trinh vo nghiem!\n");
}
return 0;
}
Quảng cáo
Bạn cần hỏi gì?
Câu hỏi hot cùng chủ đề
-
Đã trả lời bởi chuyên gia
55575 -
Đã trả lời bởi chuyên gia
31520 -
30060
