Viết chương trình hoàn chỉnh thực hiện lần lượt các công việc sau.
– Lập thủ tục (Procedure) nhập ba số thực dương a, b, c từ bàn phím.
– Viết hàm (Function) tính diện tích của tam giác?
Chạy chương trình với bộ test sau:
Nhập a = 5
Nhập b= 6
Nhập c=7
Dien tich = 14,70
procedure nhap;
begin
write(‘Nhap a: ‘); readln(a);
write(‘Nhap b: ‘); readln(b);
write(‘Nhap c: ‘); readln(c);
end;
function dttg(a,b,c:integer):real;
var p:real;
begin
p:=(a+b+c)/2;
exit(sqrt(p*(p-a)*(p-b)*(p-c);
end.
–
procedure nhap;
begin
write(‘Nhap a: ‘); readln(a);
write(‘Nhap b: ‘); readln(b);
write(‘Nhap c: ‘); readln(c);
end;
–
function dttg(a,b,c:integer):real;
var p:real;
begin
p:=(a+b+c)/2;
exit(sqrt(p*(p-a)*(p-b)*(p-c));
end;